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