Created
June 19, 2017 07:35
-
-
Save harrietty/a018a93e4047d52d02a54be0b0ea14c2 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
const CURR_DIR = process.cwd(); | |
inquirer.prompt(QUESTIONS) | |
.then(answers => { | |
const projectChoice = answers['project-choice']; | |
const projectName = answers['project-name']; | |
const templatePath = `${__dirname}/templates/${projectChoice}`; | |
fs.mkdirSync(`${CURR_DIR}/${projectName}`); | |
createDirectoryContents(templatePath, projectName); | |
}); | |
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'); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment