ora
Advanced tools
Comparing version 2.1.0 to 3.0.0
29
index.js
@@ -38,3 +38,3 @@ 'use strict'; | ||
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); | ||
@@ -63,3 +63,3 @@ // Set *after* `this.stream` | ||
frame() { | ||
const frames = this.spinner.frames; | ||
const {frames} = this.spinner; | ||
let frame = frames[this.frameIndex]; | ||
@@ -77,3 +77,3 @@ | ||
clear() { | ||
if (!this.enabled) { | ||
if (!this.isEnabled || !this.stream.isTTY) { | ||
return this; | ||
@@ -107,9 +107,15 @@ } | ||
if (!this.enabled || this.isSpinning) { | ||
if (!this.isEnabled) { | ||
this.stream.write(`- ${this.text}\n`); | ||
return this; | ||
} | ||
if (this.isSpinning) { | ||
return this; | ||
} | ||
if (this.hideCursor) { | ||
cliCursor.hide(this.stream); | ||
} | ||
this.render(); | ||
@@ -122,3 +128,3 @@ this.id = setInterval(this.render.bind(this), this.interval); | ||
stop() { | ||
if (!this.enabled) { | ||
if (!this.isEnabled) { | ||
return this; | ||
@@ -154,14 +160,3 @@ } | ||
stopAndPersist(options) { | ||
if (!this.enabled) { | ||
return this; | ||
} | ||
// TODO: Remove in the next major version | ||
if (typeof options === 'string') { | ||
throw new TypeError('This argument now accepts an options object, not a string'); | ||
} | ||
options = options || {}; | ||
stopAndPersist(options = {}) { | ||
this.stop(); | ||
@@ -168,0 +163,0 @@ this.stream.write(`${options.symbol || ' '} ${options.text || this.text}\n`); |
{ | ||
"name": "ora", | ||
"version": "2.1.0", | ||
"description": "Elegant terminal spinner", | ||
"license": "MIT", | ||
"repository": "sindresorhus/ora", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"cli", | ||
"spinner", | ||
"spinners", | ||
"terminal", | ||
"term", | ||
"console", | ||
"ascii", | ||
"unicode", | ||
"loading", | ||
"indicator", | ||
"progress", | ||
"busy", | ||
"wait", | ||
"idle" | ||
], | ||
"dependencies": { | ||
"chalk": "^2.3.1", | ||
"cli-cursor": "^2.1.0", | ||
"cli-spinners": "^1.1.0", | ||
"log-symbols": "^2.2.0", | ||
"strip-ansi": "^4.0.0", | ||
"wcwidth": "^1.0.1" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"get-stream": "^3.0.0", | ||
"xo": "*" | ||
} | ||
"name": "ora", | ||
"version": "3.0.0", | ||
"description": "Elegant terminal spinner", | ||
"license": "MIT", | ||
"repository": "sindresorhus/ora", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=6" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"cli", | ||
"spinner", | ||
"spinners", | ||
"terminal", | ||
"term", | ||
"console", | ||
"ascii", | ||
"unicode", | ||
"loading", | ||
"indicator", | ||
"progress", | ||
"busy", | ||
"wait", | ||
"idle" | ||
], | ||
"dependencies": { | ||
"chalk": "^2.3.1", | ||
"cli-cursor": "^2.1.0", | ||
"cli-spinners": "^1.1.0", | ||
"log-symbols": "^2.2.0", | ||
"strip-ansi": "^4.0.0", | ||
"wcwidth": "^1.0.1" | ||
}, | ||
"devDependencies": { | ||
"ava": "1.0.0-beta.6", | ||
"get-stream": "^3.0.0", | ||
"xo": "*" | ||
} | ||
} |
@@ -39,4 +39,2 @@ # ora [![Build Status](https://travis-ci.org/sindresorhus/ora.svg?branch=master)](https://travis-ci.org/sindresorhus/ora) | ||
It will gracefully not do anything when there's no TTY or when running in a CI. | ||
### ora([options|text]) | ||
@@ -105,3 +103,3 @@ | ||
##### enabled | ||
##### isEnabled | ||
@@ -112,2 +110,4 @@ Type: `boolean` | ||
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 | ||
@@ -114,0 +114,0 @@ |
10184
146