Skip to content

Instantly share code, notes, and snippets.

@DKunin
Last active September 8, 2016 09:48
Show Gist options
  • Select an option

  • Save DKunin/ab06fcbc8c183a239a388fa07a8bb18d to your computer and use it in GitHub Desktop.

Select an option

Save DKunin/ab06fcbc8c183a239a388fa07a8bb18d to your computer and use it in GitHub Desktop.
copyRecursiveSync
var copyRecursiveSync = function(src, dest) {
if (existsAndAFolder(src)) {
if (!existsAndAFolder(dest)) {
fs.mkdirSync(dest);
}
fs.readdirSync(src).forEach(function(childItemName) {
copyRecursiveSync(path.join(src, childItemName), path.join(dest, childItemName));
});
} else if (!fs.existsSync(dest)) {
fs.createReadStream(src).pipe(fs.createWriteStream(dest));
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment