Merge pull request #129 from validalias/omi-cli-init-method-fix

Save project name on package.json
This commit is contained in:
当耐特 2018-10-29 15:47:34 +08:00 committed by GitHub
commit 7881c580e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -80,6 +80,11 @@ function init(args) {
renameSync(join(dest, "gitignore"), join(dest, ".gitignore"));
if (customPrjName) {
try {
const appPackage = require(join(dest,"package.json"));
appPackage.name = customPrjName;
fs.writeFile(join(dest,"package.json"), JSON.stringify(appPackage, null, 2), (err) => {
if (err) return console.log(err);
})
process.chdir(customPrjName);
} catch (err) {
console.log(error(err));