Fix config --new

This commit is contained in:
Bryan Ashby 2016-07-18 22:03:23 -06:00
parent 985d239ab9
commit 07ed70a5d0
1 changed files with 12 additions and 9 deletions

View File

@ -1,6 +1,7 @@
#!/usr/bin/env node #!/usr/bin/env node
/* jslint node: true */ /* jslint node: true */
/* eslint-disable no-console */
'use strict'; 'use strict';
// ENiGMA½ // ENiGMA½
@ -18,14 +19,14 @@ const fs = require('fs');
const hjson = require('hjson'); const hjson = require('hjson');
const paths = require('path'); const paths = require('path');
var argv = require('minimist')(process.argv.slice(2)); const argv = require('minimist')(process.argv.slice(2));
const ExitCodes = { const ExitCodes = {
SUCCESS : 0, SUCCESS : 0,
ERROR : -1, ERROR : -1,
BAD_COMMAND : -2, BAD_COMMAND : -2,
BAD_ARGS : -3, BAD_ARGS : -3,
} };
const USAGE_HELP = { const USAGE_HELP = {
General : General :
@ -45,7 +46,7 @@ commands:
valid args: valid args:
--user USERNAME : specify username --user USERNAME : specify username
-- password PASS : specify password (to reset) --password PASS : specify password (to reset)
`, `,
Config : Config :
@ -54,7 +55,7 @@ valid args:
valid args: valid args:
--new : generate a new/initial configuration --new : generate a new/initial configuration
` `
} };
function printUsage(command) { function printUsage(command) {
console.error(USAGE_HELP[command]); console.error(USAGE_HELP[command]);
@ -127,7 +128,9 @@ function handleUserCommand() {
} }
function getAnswers(questions, cb) { function getAnswers(questions, cb) {
inq.prompt(questions, cb); inq.prompt(questions).then( answers => {
return cb(answers);
});
} }
function getDefaultConfigPath() { function getDefaultConfigPath() {
@ -212,7 +215,7 @@ function makeMsgConfAreaName(s) {
return s.toLowerCase().replace(/\s+/g, '_'); return s.toLowerCase().replace(/\s+/g, '_');
} }
function askQuestions(cb) { function askNewConfigQuestions(cb) {
const ui = new inq.ui.BottomBar(); const ui = new inq.ui.BottomBar();
@ -343,7 +346,7 @@ function handleConfigCommand() {
} }
if(argv.new) { if(argv.new) {
askQuestions( (err, configPath, config) => { askNewConfigQuestions( (err, configPath, config) => {
if(err) { if(err) {
return; return;
} }