Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let iObjectStorage = 0
if (objectStorageResources.resources.length > 1) {
iObjectStorage = await picker(
`${bold('Object Storage Instances')} ${dim(
'(Use arrow keys and enter to choose)'
)}`,
objectStorageResources.resources.map(a => a.name),
{
default: 0,
returnIndex: true
}
)
}
const objectStorage = objectStorageResources.resources[iObjectStorage]
process.stdout.write(eraseLines(2))
console.log(`Object Storage Instance ${cyan.bold(objectStorage.name)}`)
console.log()
spinner.start()
const machineLearningResources = await request({
url: machineLearningResourcesEndpoint,
method: 'GET',
headers: {
Authorization: 'bearer ' + upgradedToken.access_token
},
json: true
})
spinner.stop()
if (machineLearningResources.next_url) {
// TODO: check if there are more accounts
// Until the first keypress
valid = true,
// Can be:
// - `false`, which does nothing
// - `cc`, for credit cards
// - `date`, for dates in the mm / yyyy format
mask = false,
placeholder = '',
abortSequences = new Set(['\x03']),
eraseSequences = new Set([ESCAPES.BACKSPACE, ESCAPES.CTRL_H]),
resolveChars = new Set([ESCAPES.CARRIAGE]),
stdin = process.stdin,
stdout = process.stdout,
// Char to print before resolving/rejecting the promise
// If `false`, nothing will be printed
trailing = ansiEscapes.eraseLines(1),
// Gets called on each keypress;
// `data` contains the current keypress;
// `futureValue` contains the current value + the
// Keypress in the correct place
validateKeypress = (data, futureValue) => true, // eslint-disable-line no-unused-vars
// Get's called before the promise is resolved
// Returning `false` here will prevent the user from submiting the value
validateValue = data => true, // eslint-disable-line no-unused-vars
// Receives the value of the input and should return a string
// Or false if no autocomplion is available
autoComplete = value => false, // eslint-disable-line no-unused-vars
// Tab
// Right arrow
autoCompleteChars = new Set(['\t', '\x1b[C']),
// If true, converts everything the user types to to lowercase
forceLowerCase = false
if (clear) {
const linesToClear = state.error ? 15 : 14;
process.stdout.write(ansiEscapes.eraseLines(linesToClear));
}
console.log(
success(
`${state.cardNumber.brand ||
state.cardNumber.card.brand} ending in ${res.last4 ||
res.card.last4} was added to ${chalk.bold(contextName)}`
)
);
} catch (err) {
stopSpinner();
const linesToClear = state.error ? 15 : 14;
process.stdout.write(ansiEscapes.eraseLines(linesToClear));
state.error = `${chalk.red(
'> Error!'
)} ${err.message} Please make sure the info is correct`;
await render();
}
}
function writeToConsole(output: string) {
process.stdout.write(ansiEscapes.eraseLines(previousLineCount) + output);
previousLineCount = output.split("\n").length;
}
rl.input.on('keypress', (_, key) => {
if (key.name === 'up') {
index = Math.max(0, index - 1)
process.stdout.write(eraseLines(delegate.windowSize))
renderItems(items, delegate, index)
} else if (key.name === 'down') {
index = Math.min(items.length - 1, index + 1)
process.stdout.write(eraseLines(delegate.windowSize))
renderItems(items, delegate, index)
} else if (key.name === 'return') {
resolve(index)
}
})
})
rl.input.on('keypress', (_, key) => {
if (key.name === 'tab' && charCount === 0) {
process.stdout.write(eraseLines(1))
rl.setPrompt(question)
rl.prompt()
} else if (key.name === 'backspace' && charCount === 0) {
process.stdout.write(eraseLines(1))
rl.setPrompt(prompt)
rl.prompt()
} else if (key.name === 'backspace') {
charCount--
} else {
charCount++
}
})
exports.clearLine = function(rl, len) {
rl.output.write(ansiEscapes.eraseLines(len));
};
render.clear = () => {
stream.write(ansiEscapes.eraseLines(prevLineCount));
prevLineCount = 0;
};
module.exports = n => process.stdout.write(ansiEscapes.eraseLines(n))
val.substr(0, val.length + caretOffset - 1) +
val.substr(val.length + caretOffset)
} else {
if (resolveChars.has(s)) {
restore()
return resolve(val)
}
const add = forceLowerCase ? s.toLowerCase() : s
val =
val.substr(0, val.length + caretOffset) +
add +
val.substr(val.length + caretOffset)
}
process.stdout.write(ansi.eraseLines(1) + chalk.dim(question) + val)
if (caretOffset) {
process.stdout.write(ansi.cursorBackward(Math.abs(caretOffset)))
}
}