diff --git a/lib/cli/create.js b/lib/cli/create.js index 7ba3c46..2e25a03 100644 --- a/lib/cli/create.js +++ b/lib/cli/create.js @@ -17,21 +17,21 @@ const start = require('./start'); * Create a new app with folder structure and files */ const create = function (name) { - name = name || 'my-deployd-app'; - if (test('-d', name)) { - return console.info(`${name} already exists in this directory`); + const newName = name || 'my-deployd-app'; + if (test('-d', newName)) { + return console.info(`${newName} already exists in this directory`); } - mkdir('-p', name); - cp('-Rf', path.join(__dirname, '../createtemplate/*'), name); - mkdir('-p', `${name}/.dpd`); - mkdir('-p', `${name}/.dpd/pids`); - ('').to(`${name}/.dpd/pids/mongod`); + mkdir('-p', newName); + cp('-Rf', path.join(__dirname, '../createtemplate/*'), newName); + mkdir('-p', `${newName}/.dpd`); + mkdir('-p', `${newName}/.dpd/pids`); + ('').to(`${newName}/.dpd/pids/mongod`); ('# npm\r\nnode_modules/\r\nnpm-debug.log\r\n\r\n# deployd\r\n.dpd/\r\ndata/') - .to(`${name}/.gitignore`); - rm(ls('-R', name).filter(p => path.basename(p) === 'PLACEHOLDER').map(p => `${name}/${p}`)); + .to(`${newName}/.gitignore`); + rm(ls('-R', newName).filter(p => path.basename(p) === 'PLACEHOLDER').map(p => `${newName}/${p}`)); - process.chdir(name); + process.chdir(newName); console.log('dpd is installing the dependencies... please be patient (this may take a few minutes)'); const child = exec('npm install', @@ -40,10 +40,10 @@ const create = function (name) { console.log(stderr); console.log(`npm install error: ${error}`); } else if (program.dashboard || program.open) { - start(`${name}/app.dpd`); + start(`${newName}/app.dpd`); } else { console.info('to start your app:'); - console.info('\t$ cd', name); + console.info('\t$ cd', newName); console.info('\t$ dpd'); } }); diff --git a/lib/keys.js b/lib/keys.js index 49c2425..cde9f67 100644 --- a/lib/keys.js +++ b/lib/keys.js @@ -41,8 +41,10 @@ Keys.prototype.create = function (fn) { this.readFile((err, data) => { if (err) return fn(err); - data[key] = true; - keys.writeFile(data, (errW) => { + const fileData = data; + + fileData[key] = true; + keys.writeFile(fileData, (errW) => { fn(errW, key); }); });