Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var validator = option.validator;
option.validator = function(line, next) {
if (line === '?') {
return next(false);
} else if (validator) {
if (validator.test) {
return next(validator.test(line));
} else if (typeof validator === 'function') {
return validator.length < 2 ? next(validator(line)) : validator(line, next);
}
}
next(true);
};
// Actually get user input.
prompt.start();
prompt.getInput(option, function(err, line) {
if (err) { return done(err); }
option.validator = validator;
result[option.name] = line;
done();
});
});
}, function(err) {
} else if (validator) {
if (validator.test) {
return next(validator.test(line));
} else if (typeof validator === 'function') {
return validator.length < 2 ? next(validator(line)) : validator(line, next);
}
}
next(true);
};
// Actually get user input.
if (useDefaults) {
result[option.name] = option.default;
done();
} else {
prompt.start();
prompt.getInput(option, function(err, line) {
if (err) { return done(err); }
option.validator = validator;
result[option.name] = line;
done();
});
}
});
}, function() {
var validator = option.validator;
option.validator = function(line, next) {
if (line === '?') {
return next(false);
} else if (validator) {
if (validator.test) {
return next(validator.test(line));
} else if (typeof validator === 'function') {
return validator.length < 2 ? next(validator(line)) : validator(line, next);
}
}
next(true);
};
// Actually get user input.
prompt.start();
prompt.getInput(option, function(err, line) {
if (err) { return done(err); }
option.validator = validator;
result[option.name] = line;
done();
});
});
}, function() {
function doPrompt() {
prompt.start();
prompt.getInput(option, function(err, line) {
if (err) { return done(err); }
result[option.name] = line;
done();
});
}
// If the default value is a function, execute that function, using the