Skip to content

Commit

Permalink
Rename the enabled option to isEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jul 17, 2018
1 parent d1f8d85 commit fc5c660
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions index.js
Expand Up @@ -35,7 +35,7 @@ class Ora {
this.stream = this.options.stream;
this.id = null;
this.frameIndex = 0;
this.enabled = typeof this.options.enabled === 'boolean' ? this.options.enabled : ((this.stream && this.stream.isTTY) && !process.env.CI);
this.isEnabled = typeof this.options.isEnabled === 'boolean' ? this.options.isEnabled : ((this.stream && this.stream.isTTY) && !process.env.CI);

// Set *after* `this.stream`
this.text = this.options.text;
Expand Down Expand Up @@ -72,7 +72,7 @@ class Ora {
}

clear() {
if (!this.enabled || !this.stream.isTTY) {
if (!this.isEnabled || !this.stream.isTTY) {
return this;
}

Expand Down Expand Up @@ -101,7 +101,7 @@ class Ora {
this.text = text;
}

if (!this.enabled) {
if (!this.isEnabled) {
this.stream.write(`- ${this.text}\n`);
return this;
}
Expand All @@ -121,7 +121,7 @@ class Ora {
}

stop() {
if (!this.enabled) {
if (!this.isEnabled) {
return this;
}

Expand Down
4 changes: 2 additions & 2 deletions readme.md
Expand Up @@ -99,13 +99,13 @@ Stream to write the output.

You could for example set this to `process.stdout` instead.

##### enabled
##### isEnabled

Type: `boolean`

Force enable/disable the spinner. If not specified, the spinner will be enabled if the `stream` is being run inside a TTY context (not spawned or piped) and/or not in a CI environment.

Note that `{enabled: false}` doesn't mean it won't output anything. It just means it won't output the spinner, colors, and other ansi escape codes. It will still log text.
Note that `{isEnabled: false}` doesn't mean it won't output anything. It just means it won't output the spinner, colors, and other ansi escape codes. It will still log text.

### Instance

Expand Down
22 changes: 11 additions & 11 deletions test.js
Expand Up @@ -23,7 +23,7 @@ const doSpinner = async (fn, extraOptions = {}) => {
stream,
text: 'foo',
color: false,
enabled: true,
isEnabled: true,
...extraOptions
});

Expand All @@ -50,7 +50,7 @@ test('title shortcut', async t => {
const spinner = ora('foo');
spinner.stream = stream;
spinner.color = false;
spinner.enabled = true;
spinner.isEnabled = true;
spinner.start();
t.true(spinner.isSpinning);
spinner.stop();
Expand Down Expand Up @@ -78,11 +78,11 @@ test('chain call to `.start()` with constructor', t => {
const spinner = new Ora({
stream: getPassThroughStream(),
text: 'foo',
enabled: true
isEnabled: true
}).start();

t.truthy(spinner.id);
t.true(spinner.enabled);
t.true(spinner.isEnabled);
});

test('.succeed()', macro, spinner => {
Expand Down Expand Up @@ -122,13 +122,13 @@ test('.start(text)', macro, spinner => {
spinner.stopAndPersist();
}, /Test text/);

test('.start() - enabled:false outputs text', macro, spinner => {
test('.start() - isEnabled:false outputs text', macro, spinner => {
spinner.stop();
}, /- foo/, {enabled: false});
}, /- foo/, {isEnabled: false});

test('.stopAndPersist() - enabled:false outputs text', macro, spinner => {
test('.stopAndPersist() - isEnabled:false outputs text', macro, spinner => {
spinner.stopAndPersist({symbol: '@', text: 'all done'});
}, /- foo\n@ all done/, {enabled: false});
}, /- foo\n@ all done/, {isEnabled: false});

test('.promise() - resolves', async t => {
const stream = getPassThroughStream();
Expand All @@ -139,7 +139,7 @@ test('.promise() - resolves', async t => {
stream,
text: 'foo',
color: false,
enabled: true
isEnabled: true
});

await resolves;
Expand All @@ -157,7 +157,7 @@ test('.promise() - rejects', async t => {
stream,
text: 'foo',
color: false,
enabled: true
isEnabled: true
});

try {
Expand Down Expand Up @@ -190,7 +190,7 @@ test('erases wrapped lines', t => {
stream,
text: 'foo',
color: false,
enabled: true
isEnabled: true
});

spinner.render();
Expand Down

0 comments on commit fc5c660

Please sign in to comment.