Define a common helper for prompting to the user consistently
This commit is contained in:
parent
6c546b2098
commit
770ede0587
@ -15,8 +15,8 @@ program
|
||||
log.error(`User ${colors.bold(name)} already exists.`);
|
||||
return;
|
||||
}
|
||||
require("read")({
|
||||
prompt: log.rawInfo("Enter password: "),
|
||||
log.prompt({
|
||||
text: "Enter password:",
|
||||
silent: true
|
||||
}, function(err, password) {
|
||||
if (!password) {
|
||||
|
@ -17,8 +17,8 @@ program
|
||||
}
|
||||
var file = Helper.getUserConfigPath(name);
|
||||
var user = require(file);
|
||||
require("read")({
|
||||
prompt: log.rawInfo("Enter new password: "),
|
||||
log.prompt({
|
||||
text: "Enter new password:",
|
||||
silent: true
|
||||
}, function(err, password) {
|
||||
if (err) {
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
var colors = require("colors/safe");
|
||||
var moment = require("moment");
|
||||
const read = require("read");
|
||||
var Helper = require("./helper");
|
||||
|
||||
function timestamp(type, messageArgs) {
|
||||
@ -31,7 +32,7 @@ exports.debug = function() {
|
||||
console.log.apply(console, timestamp(colors.green("[DEBUG]"), arguments));
|
||||
};
|
||||
|
||||
exports.rawInfo = function() {
|
||||
const newArguments = timestamp(colors.blue("[INFO]"), arguments);
|
||||
return Array.prototype.slice.call(newArguments).join(" ");
|
||||
exports.prompt = (options, callback) => {
|
||||
options.prompt = timestamp(colors.cyan("[PROMPT]"), [options.text]).join(" ");
|
||||
read(options, callback);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user