Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
text: options
};
}
this.options = extend(true, {
text: '',
color: 'cyan',
stream: process.stderr
}, options);
const sp = this.options.spinner;
this.spinner = typeof sp === 'object'
? sp
: (process.platform === 'win32'
? cliSpinners.line
: (cliSpinners[sp] || cliSpinners.dots)); // eslint-disable-line no-nested-ternary
if (this.spinner.frames === undefined) {
throw new Error('Spinner must define `frames`');
}
this.text = this.options.text;
this.color = this.options.color;
this.interval = this.options.interval || this.spinner.interval || 100;
this.stream = this.options.stream;
this.id = null;
this.frameIndex = 0;
this.enabled = this.options.enabled || ((this.stream && this.stream.isTTY) && !process.env.CI);
}
frame() {
const indicator = (prompt, choice, index, options) => {
if (choice.spinner) return choice.spinner;
let opts = { ...choice, ...options };
let ind = choice.origIndicator || (choice.origIndicator = choice.indicator);
let framerate = opts.framerate || opts.interval || spinners.dots.interval;
let colorRate = opts.colorRate || framerate;
let animation = choice.spinner = new Animate({
maxTime: 5000,
framerate,
frames: opts.frames || spinners.dots.frames,
index,
onStart() {
choice.completing = true;
choice.colorFrame = 0;
choice.colorInt = setInterval(() => {
choice.colorFrame++;
}, colorRate);
},
async onUpdate() {
let color = colors[animation.ele(keys, choice.colorFrame)];
choice.indicator = color(animation.frame());
await prompt.render();
},
onFail() {
// choice.hint = prompt.styles.disabled('(cannot resolve choice)');
// choice.disabled = true;
indexerCall(wallet, 'buy', 'pay', (result, values) => {
const spinnies = new Spinnies({
spinner: cliSpinners.dots,
succeedColor: chalk.white,
})
prompt.get(getFields(['signerAmount'], 'buy', 'buy'), values2 => {
console.log()
let hasAtLeastOne = false
const locators = result.locators
for (let i = 0; i < locators.length; i++) {
try {
locators[i] = ethers.utils.parseBytes32String(locators[i])
} catch (e) {
console.log(`Could not parse (${locators[i]})`)
locators[i] = false
}
if (locators[i]) {
hasAtLeastOne = true
spinnies.add(locators[i], {
constructor(args) {
Object.assign(this, {
spinner : cliSpinners.dots,
spinnerColor : 'black',
frameIndex : 0,
intervalId : undefined,
colors,
}, args);
}
get icon() {
let icon = '';
if (this.iconFrame >= cliSpinners.dots.frames.length)
this.iconFrame = 0;
switch (this._state) {
case 'active':
icon = chalk.blue(cliSpinners.dots.frames[this.iconFrame++]);
break;
case 'completed':
icon = figures.tick;
break;
case 'failed':
icon = figures.cross;
break;
case 'warn':
icon = figures.warning;
break;
default:
icon = '-';
break;
}
return `${icon} `;
}
const indicator = (prompt, choice, index, options) => {
if (choice.spinner) return choice.spinner;
let opts = { ...choice, ...options };
let ind = choice.origIndicator || (choice.origIndicator = choice.indicator);
let framerate = opts.framerate || opts.interval || spinners.dots.interval;
let colorRate = opts.colorRate || framerate;
let animation = choice.spinner = new Animate({
maxTime: 5000,
framerate,
frames: opts.frames || spinners.dots.frames,
index,
onStart() {
choice.completing = true;
choice.colorFrame = 0;
choice.colorInt = setInterval(() => {
choice.colorFrame++;
}, colorRate);
},
async onUpdate() {
let color = colors[animation.ele(keys, choice.colorFrame)];
choice.indicator = color(animation.frame());
onChoice(state, choice, i) {
indicator(prompt, choice, i, { maxTime: 6000, ...spinners.dots, colorRate: 2000 });
}
},
renderDepsTree(depsTree: DepsTree, output: string[] = []) {
let indent = Array(depsTree.depth * this.props.indent)
.fill(' ')
.join('')
let frames = Spinners.dots.frames as string[]
let symbol = {
[TaskState.waiting]: chalk.gray(logFigures.ellipsis),
[TaskState.pending]: chalk.blueBright(logFigures.arrowRight),
[TaskState.loading]: chalk.cyan(frames[this.count(depsTree.uid) % frames.length]),
[TaskState.succeeded]: chalk.green(logFigures.tick),
[TaskState.failed]: chalk.red(logFigures.cross),
[TaskState.skipped]: chalk.yellow(logFigures.info),
...this.props.symbolMap,
}[depsTree.state]
let color =
(this.props.grayState || [TaskState.waiting]).indexOf(depsTree.state) >= 0
? f => chalk.gray(f)
: f => f
let skipped = depsTree.state === TaskState.skipped
output.push(
`${indent}${symbol} ${color(depsTree.task.name)}${skipped ? chalk.gray(` [skipped]`) : ''}${depsTree.priority ? chalk.gray(` [priority: ${depsTree.priority}]`) : ''}`,
constructor() {
this.spinner = {
sprite: spinners.dots,
style: subtle,
frame: 0,
intervalId: null
}
this.spinnerText = ''
this.statusText = ''
this.status = null
this.warningsText = ''
this.text = ''
this.startTime = 0
this.fileTime = 0
this.fastest = { time: Infinity, title: 'n/a' }
this.slowest = { time: 0, title: 'n/a' }
this.race = null
this.file = ''