Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
question.when = async function(answers) {
let reason,
result,
opaque = false
// fetch values
const value = await Promise.resolve(
fetch(question, question.default, answers)
)
const values = Object.assign({ [name]: value }, defaults, answers)
// check args
const args = arg ? [name, arg] : [name]
for (const _arg of args) {
const _value = getarg(process.argv, _arg)
if (_value != null) {
opaque = true
defaults[name] = _value === 0.1 ? '0.10' : _value
reason = 'arg'
}
}
// check user
if (user && !reason && user[name] != null) {
defaults[name] = user[name]
reason = 'package'
}
// fallback to other checks if no arg
if (!reason) {
// check when and ignore