Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function rimraf(dirPath) {
if (fs.existsSync(dirPath)) {
fs.readdirSync(dirPath).forEach((entry) => {
const entryPath = path.join(dirPath, entry);
if (fs.lstatSync(entryPath).isDirectory()) {
rimraf(entryPath);
} else {
fs.unlinkSync(entryPath);
}
});
fs.rmdirSync(dirPath);
}
}
dirNames.reduce((accumDir, currentdir) => {
const jointDir = path.join(accumDir, currentdir);
if (!fs.existsSync(jointDir)) {
fs.mkdirSync(jointDir);
}
return jointDir;
}, '');
}
fs.emptydirSync = (dir) => {
if (!fs.existsSync(dir)) {
createDir(dir);
} else {
rimraf(dir);
}
};
files.forEach((file) => {
const curSource = path.join(src, file);
const curDest = path.join(dest, file);
if (fs.lstatSync(curSource).isDirectory()) {
if (!fs.existsSync(curDest)) {
createDir(curDest);
}
copyDirSync(curSource, curDest);
} else {
copyFileSync(curSource, curDest);
}
});
}