Socket
Socket
Sign inDemoInstall

ora

Package Overview
Dependencies
19
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.0 to 2.0.0

58

index.js

@@ -6,3 +6,7 @@ 'use strict';

const logSymbols = require('log-symbols');
const stripAnsi = require('strip-ansi');
const wcwidth = require('wcwidth');
const TEXT = Symbol('text');
class Ora {

@@ -29,4 +33,4 @@ constructor(options) {

this.text = this.options.text;
this.color = this.options.color;
this.hideCursor = this.options.hideCursor !== false;
this.interval = this.options.interval || this.spinner.interval || 100;

@@ -37,3 +41,20 @@ this.stream = this.options.stream;

this.enabled = typeof this.options.enabled === 'boolean' ? this.options.enabled : ((this.stream && this.stream.isTTY) && !process.env.CI);
// Set *after* `this.stream`
this.text = this.options.text;
this.linesToClear = 0;
}
get text() {
return this[TEXT];
}
set text(value) {
this[TEXT] = value;
const columns = this.stream.columns || 80;
this.lineCount = stripAnsi('--' + value).split('\n').reduce((count, line) => {
return count + Math.max(1, Math.ceil(wcwidth(line) / columns));
}, 0);
}
frame() {

@@ -51,2 +72,3 @@ const frames = this.spinner.frames;

}
clear() {

@@ -57,13 +79,22 @@ if (!this.enabled) {

this.stream.clearLine();
this.stream.cursorTo(0);
for (let i = 0; i < this.linesToClear; i++) {
if (i > 0) {
this.stream.moveCursor(0, -1);
}
this.stream.clearLine();
this.stream.cursorTo(0);
}
this.linesToClear = 0;
return this;
}
render() {
this.clear();
this.stream.write(this.frame());
this.linesToClear = this.lineCount;
return this;
}
start(text) {

@@ -78,3 +109,5 @@ if (text) {

cliCursor.hide(this.stream);
if (this.hideCursor) {
cliCursor.hide(this.stream);
}
this.render();

@@ -85,2 +118,3 @@ this.id = setInterval(this.render.bind(this), this.interval);

}
stop() {

@@ -95,18 +129,25 @@ if (!this.enabled) {

this.clear();
cliCursor.show(this.stream);
if (this.hideCursor) {
cliCursor.show(this.stream);
}
return this;
}
succeed(text) {
return this.stopAndPersist({symbol: logSymbols.success, text});
}
fail(text) {
return this.stopAndPersist({symbol: logSymbols.error, text});
}
warn(text) {
return this.stopAndPersist({symbol: logSymbols.warning, text});
}
info(text) {
return this.stopAndPersist({symbol: logSymbols.info, text});
}
stopAndPersist(options) {

@@ -117,8 +158,5 @@ if (!this.enabled) {

// Legacy argument
// TODO: Deprecate sometime in the future
// TODO: Remove in the next major version
if (typeof options === 'string') {
options = {
symbol: options
};
throw new TypeError('This argument now accepts an options object, not a string');
}

@@ -125,0 +163,0 @@

95

package.json
{
"name": "ora",
"version": "1.4.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.1.0",
"cli-cursor": "^2.1.0",
"cli-spinners": "^1.0.1",
"log-symbols": "^2.1.0"
},
"devDependencies": {
"ava": "*",
"get-stream": "^3.0.0",
"strip-ansi": "^3.0.1",
"xo": "*"
}
"name": "ora",
"version": "2.0.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": "*"
}
}

@@ -13,6 +13,8 @@ # ora [![Build Status](https://travis-ci.org/sindresorhus/ora.svg?branch=master)](https://travis-ci.org/sindresorhus/ora)

```
$ npm install --save ora
$ npm install ora
```
*Show your support for Ora by buying this excellent [Node.js course](https://LearnNode.com/friend/AWESOME).*
<a href="https://www.patreon.com/sindresorhus">
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
</a>

@@ -36,3 +38,3 @@

It will gracefully not do anything when there's no TTY or when in a CI.
It will gracefully not do anything when there's no TTY or when running in a CI.

@@ -77,2 +79,9 @@ ### ora([options|text])

##### hideCursor
Type: `boolean`<br>
Default: `true`
Set to `false` to stop Ora from hiding the cursor.
##### interval

@@ -79,0 +88,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc