Created
June 19, 2017 07:47
-
-
Save harrietty/cc490c4c7e980da09c701d3d0f01a852 to your computer and use it in GitHub Desktop.
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
function createDirectoryContents (templatePath, newProjectPath) { | |
const filesToCreate = fs.readdirSync(templatePath); | |
filesToCreate.forEach(file => { | |
const origFilePath = `${templatePath}/${file}`; | |
// get stats about the current file | |
const stats = fs.statSync(origFilePath); | |
if (stats.isFile()) { | |
const contents = fs.readFileSync(origFilePath, 'utf8'); | |
const writePath = `${CURR_DIR}/${newProjectPath}/${file}`; | |
fs.writeFileSync(writePath, contents, 'utf8'); | |
} else if (stats.isDirectory()) { | |
fs.mkdirSync(`${CURR_DIR}/${newProjectPath}/${file}`); | |
// recursive call | |
createDirectoryContents(`${templatePath}/${file}`, `${newProjectPath}/${file}`); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment