@forwardslashns/fws-cli
Version:
CLI meant to work together with other Forwardslash boilerplates.
24 lines (22 loc) • 813 B
JavaScript
import { lstat, unlink, rmdir } from 'fs/promises';
import { relative } from 'path';
import { getLogMessageInline } from './getLogMessageInline.js';
export const removeNonSvgFiles = (filePath, svgDirPath) => {
try {
if (lstat(filePath).isDirectory())
rmdir(filePath, (error) => {
if (error) console.log(error);
else
getLogMessageInline(
`Deleted '${relative(svgDirPath, filePath)}' as it is not an SVG file!`,
'yellow'
);
});
else {
unlink(filePath);
getLogMessageInline(`Deleted '${relative(svgDirPath, filePath)}' as it is not an SVG file!`, 'yellow');
}
} catch (error) {
console.log(error);
}
};