Last active
April 4, 2018 18:32
-
-
Save bodadotsh/70db2fe98d00d9eab158c5bf5118af2b to your computer and use it in GitHub Desktop.
Copy a folder and subfolders without all the `node_modules` folders within... tested with Node v9.10.1
This file contains 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
// yarn add fs-extra --dev | |
const fs = require("fs-extra"); | |
console.log("*** start ***"); | |
// replace ".src" with your own folder | |
fs | |
.copy("./src", "./dist", { | |
filter: path => { | |
// console.log("path ===", path); | |
// skip filter on files | |
if (fs.lstatSync(path).isFile()) return true; | |
// return false if path is directory and string contains node_modules | |
return !(path.indexOf("node_modules") > -1); | |
} | |
}) | |
.then(() => { | |
console.log("folder copied successfully!"); | |
console.log("*** end ***"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment