Define a common helper for prompting to the user consistently

This commit is contained in:
Jérémie Astori 2016-12-16 02:27:41 -05:00
parent 6c546b2098
commit 770ede0587
3 changed files with 8 additions and 7 deletions

View File

@ -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) {

View File

@ -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) {

View File

@ -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);
};