Last active
September 8, 2016 09:48
-
-
Save DKunin/ab06fcbc8c183a239a388fa07a8bb18d to your computer and use it in GitHub Desktop.
copyRecursiveSync
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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