UNPKG

@forwardslashns/fws-cli

Version:

CLI meant to work together with other Forwardslash boilerplates.

23 lines (19 loc) 640 B
import { resolve } from 'path'; export const renameSvgFiles = (svgDirPath, filePath, file) => { let newFilePath = filePath; if (file.substring(0, 4) !== 'ico-') { let newFileName = file .toLowerCase() .replace(/\.svg$/, '') .replace(/-/g, ' ') .replace(/[^\w\s]/gi, '') .replace(/\s+/g, '-') .replace(/^(-+)/, '') .replace(/(-+)$/, '') .replace(/-{2,}/g, '-') .replace(/^-/, '') .replace(/-$/, ''); newFilePath = resolve(svgDirPath, `ico-${newFileName}.svg`); } return newFilePath; };