Skip to content

Instantly share code, notes, and snippets.

@J2D2Development
Created August 25, 2017 12:59
Show Gist options
  • Save J2D2Development/3c5e08825b654e6c0350b4be7c077bba to your computer and use it in GitHub Desktop.
Save J2D2Development/3c5e08825b654e6c0350b4be7c077bba to your computer and use it in GitHub Desktop.
Insert new string into path
'use strict';
module.exports = function(filePath, additionalName) {
const filePathArray = filePath.split('.');
const lastItemInPath = filePathArray[filePathArray.length - 2];
filePathArray[filePathArray.length - 2] = `${lastItemInPath}-${additionalName}`;
return filePathArray.join('.');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment