Created
July 16, 2017 17:53
-
-
Save kenshero/e03563e1c90d6daf1e7ce2e42cbf5ba7 to your computer and use it in GitHub Desktop.
script gen file
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
const fs = require('fs') | |
const writeFileController = (pathController, moduleName) => { | |
fs.writeFile(`${pathController}/${moduleName}.js`, "", function(err) { | |
if(err) { | |
return console.log(err); | |
} | |
console.log(`Create ${moduleName} controller file success!`); | |
}) | |
} | |
const writeFileModel = (pathModel, moduleName) => { | |
fs.writeFile(`${pathModel}/${moduleName}.js`, "", function(err) { | |
if(err) { | |
return console.log(err); | |
} | |
console.log(`Create ${moduleName} model file success!`); | |
}) | |
} | |
const writeFileView = (pathView, moduleName) => { | |
fs.writeFile(`${pathView}/${moduleName}.html`, "", function(err) { | |
if(err) { | |
return console.log(err); | |
} | |
console.log(`Create ${moduleName} view file success!`); | |
}) | |
} | |
const args = process.argv.slice(2); | |
if(args[0] === "new_module") { | |
const moduleName = args[1] | |
const pathController = './Controller/' | |
const pathModel = './Model/' | |
const pathView = './View/' | |
writeFileController(pathController, moduleName) | |
writeFileModel(pathModel, moduleName) | |
writeFileView(pathView, moduleName) | |
} else { | |
console.log("Not Found Command"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment