Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(0, _classCallCheck3.default)(this, Ora);
if (typeof options === 'string') {
options = {
text: options
};
}
this.options = extend(true, {
text: '',
color: 'cyan',
stream: process.stderr
}, options);
var sp = this.options.spinner;
this.spinner = (typeof sp === 'undefined' ? 'undefined' : (0, _typeof3.default)(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;
}
options = {
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() {
set spinner(spinner) {
this.frameIndex = 0;
if (typeof spinner === 'object') {
if (spinner.frames === undefined) {
throw new Error('The given spinner must have a `frames` property');
}
this._spinner = spinner;
} else if (process.platform === 'win32') {
this._spinner = cliSpinners.line;
} else if (spinner === undefined) {
// Set default spinner
this._spinner = cliSpinners.dots;
} else if (cliSpinners[spinner]) {
this._spinner = cliSpinners[spinner];
} else {
throw new Error(`There is no built-in spinner named '${spinner}'. See https://github.com/sindresorhus/cli-spinners/blob/master/spinners.json for a full list.`);
}
this._updateInterval(this._spinner.interval);
}
Spinner = function Spinner(options) {
options = assign({
color: 'green',
text: '',
stream: process.stderr
}, options || {});
this.text = options.text;
this.color = options.color;
this.spinner = (process.platform === 'win32') ? spinners.line :
(spinners[options.spinner] || spinners.hamburger);
this.interval = this.spinner.interval || 100;
this.stream = options.stream;
this.id = null;
this.frameIndex = 0;
this.enabled = options.enabled || ((this.stream && this.stream.isTTY) && !process.env.CI);
};