From e6660308fa3f51b60f815f97a500d0450d212b94 Mon Sep 17 00:00:00 2001 From: David Baldwynn Date: Tue, 7 Jun 2016 12:56:41 -0700 Subject: [PATCH] fixed setup script modified: public/dist/application.js modified: public/dist/application.min.js --- package.json | 2 +- scripts/setup.js | 77 ++++++++++++++++++++++++------------------------ 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/package.json b/package.json index b09e0388..8cee0c90 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "scripts": { "start": "grunt", "test": "grunt test && grunt coveralls", - "postinstall": "bower install --config.interactive=false; grunt build" + "postinstall": "bower install --config.interactive=false; grunt build; node scripts/setup.js;" }, "dependencies": { "async": "^1.4.2", diff --git a/scripts/setup.js b/scripts/setup.js index 9589696b..b70ebe32 100644 --- a/scripts/setup.js +++ b/scripts/setup.js @@ -172,50 +172,51 @@ var questions = [ } ]; -console.log(chalk.green('\n\nHi, welcome to TellForm Setup')); +if(!fs.existsSync('./\.env')) { + console.log(chalk.green('\n\nHi, welcome to TellForm Setup')); -console.log(chalk.green('You should only run this the first time you setup TellForm\n--------------------------------------------------\n\n')); + console.log(chalk.green('You should only run this the first time you setup TellForm\n--------------------------------------------------\n\n')); -inquirer.prompt([questions[0]]).then(function (confirmAns) { - if(confirmAns['shouldContinue']) { + inquirer.prompt([questions[0]]).then(function (confirmAns) { + if (confirmAns['shouldContinue']) { - inquirer.prompt(questions.slice(1)).then(function (answers) { - answers['NODE_ENV'] = 'production'; - answers['SIGNUP_DISABLED'] = false ? answers['SIGNUP_DISABLED'] === false : true; + inquirer.prompt(questions.slice(1)).then(function (answers) { + answers['NODE_ENV'] = 'production'; + answers['SIGNUP_DISABLED'] = false ? answers['SIGNUP_DISABLED'] === false : true; + var email = answers['email']; + var pass = answers['password']; + delete answers['email']; + delete answers['password']; - var email = answers['email']; - var pass = answers['password']; - delete answers['email']; - delete answers['password']; + envfile.stringify(answers, function (err, str) { + fs.outputFile('./\.env', str, function (err) { + if (err) return console.error(chalk.red(err)); + console.log(chalk.green('Successfully created .env file')); + }); + user = new User({ + firstName: 'Admin', + lastName: 'Account', + email: email, + username: email, + password: pass, + provider: 'local', + roles: ['admin', 'user'] + }); - envfile.stringify(answers, function (err, str) { - fs.outputFile('..//.env', str, function(err){ - if (err) return console.error(chalk.red(err)); - console.log(chalk.green('Successfully created .env file')); - }); - user = new User({ - firstName: 'Admin', - lastName: 'Account', - email: email, - username: email, - password: pass, - provider: 'local', - roles: ['admin', 'user'] - }); + user.save(function (err) { + if (err) return console.error(chalk.red(err)); + console.log(chalk.green('Successfully created user')); + delete email; + delete pass; - user.save(function (err) { - if (err) return console.error(chalk.red(err)); - console.log(chalk.green('Successfully created user')); - delete email; - delete pass; - - console.log(chalk.green('Have fun using TellForm!')); - process.exit(1); + console.log(chalk.green('Have fun using TellForm!')); + process.exit(1); + }); }); }); - }); - } else { - console.log(chalk.green('Have fun using TellForm!')); - } -}); + } else { + console.log(chalk.green('Have fun using TellForm!')); + } + }); +}