-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a prompt before you submit a crash report. (#749)
- Loading branch information
Showing
7 changed files
with
124 additions
and
68 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Third Party Dependencies | ||
var inquirer = require('inquirer'); | ||
|
||
/* | ||
controller.menu({ | ||
// Custom prefix | ||
prefix: colors.grey('INFO '), | ||
prompt: [inquirer.prompt options], | ||
// Custom answer -> data translation | ||
translate: function(answer) { | ||
// answer => | ||
// { [prompt.name]: ... } | ||
return answer[prompt.name]; | ||
} | ||
}) => Promise | ||
*/ | ||
|
||
var Menu = {}; | ||
|
||
Menu.prompt = (setup) => { | ||
var options = setup.prompt; | ||
|
||
if (options.type === 'list') { | ||
options.choices.push('\tExit'); | ||
} | ||
|
||
// Enforce a customized prompt prefix | ||
inquirer.prompt.prompts[options.type].prototype.prefix = (str) => { | ||
// String() used to coerce an `undefined` to ''. Do not change. | ||
return String(setup.prefix) + str; | ||
}; | ||
|
||
return new Promise(function(resolve) { | ||
inquirer.prompt([options], function(answer) { | ||
if (setup.translate) { | ||
resolve(setup.translate(answer)); | ||
} else { | ||
resolve(answer); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
module.exports = Menu; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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