Skip to content

Commit

Permalink
Require Node.js 8
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Sep 22, 2019
1 parent b1f140b commit 6459090
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 33 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ node_js:
- '12'
- '10'
- '8'
- '6'
19 changes: 11 additions & 8 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ declare namespace ora {
readonly text?: string;

/**
Text to display before the spinner. No prefix text will be displayed if set to empty string.
Text to display before the spinner. No prefix text will be displayed if set to an empty string.
*/
readonly prefixText?: string;

Expand Down Expand Up @@ -70,7 +70,9 @@ declare namespace ora {
/**
Interval between each frame.
Spinners provide their own recommended interval, so you don't really need to specify this. Default value: Provided by the spinner or `100`.
Spinners provide their own recommended interval, so you don't really need to specify this.
Default: Provided by the spinner or `100`.
*/
readonly interval?: number;

Expand Down Expand Up @@ -107,12 +109,16 @@ declare namespace ora {
readonly symbol?: string;

/**
Text to be persisted after the symbol. Default: Current `text`.
Text to be persisted after the symbol.
Default: Current `text`.
*/
readonly text?: string;

/**
Text to be persisted before the symbol. No prefix text will be displayed if set to empty string. Default: Current `prefixText`.
Text to be persisted before the symbol. No prefix text will be displayed if set to an empty string.
Default: Current `prefixText`.
*/
readonly prefixText?: string;
}
Expand All @@ -129,7 +135,7 @@ declare namespace ora {
text: string;

/**
Change the text before the spinner. No prefix text will be displayed if set to empty string.
Change the text before the spinner. No prefix text will be displayed if set to an empty string.
*/
prefixText: string;

Expand Down Expand Up @@ -256,9 +262,6 @@ declare const ora: {
action: PromiseLike<unknown>,
options?: ora.Options | string
): ora.Ora;

// TODO: Remove this for the next major release
default: typeof ora;
};

export = ora;
24 changes: 12 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ class Ora {
};
}

this.options = Object.assign({
this.options = {
text: '',
color: 'cyan',
stream: process.stderr,
discardStdin: true
}, options);
discardStdin: true,
...options
};

this.spinner = this.options.spinner;

Expand Down Expand Up @@ -278,30 +279,29 @@ class Ora {
}
}

const oraFactory = function (opts) {
return new Ora(opts);
const oraFactory = function (options) {
return new Ora(options);
};

module.exports = oraFactory;
// TODO: Remove this for the next major release
module.exports.default = oraFactory;

module.exports.promise = (action, options) => {
// eslint-disable-next-line promise/prefer-await-to-then
if (typeof action.then !== 'function') {
throw new TypeError('Parameter `action` must be a Promise');
}

const spinner = new Ora(options);
spinner.start();

action.then(
() => {
(async () => {
try {
await action;
spinner.succeed();
},
() => {
} catch (_) {
spinner.fail();
}
);
})();

return spinner;
};
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
"node": ">=8"
},
"scripts": {
"test": "xo && ava && tsd"
Expand All @@ -37,18 +37,18 @@
],
"dependencies": {
"chalk": "^2.4.2",
"cli-cursor": "^2.1.0",
"cli-spinners": "^2.0.0",
"is-interactive": "^0.1.0",
"log-symbols": "^2.2.0",
"cli-cursor": "^3.1.0",
"cli-spinners": "^2.2.0",
"is-interactive": "^1.0.0",
"log-symbols": "^3.0.0",
"strip-ansi": "^5.2.0",
"wcwidth": "^1.0.1"
},
"devDependencies": {
"@types/node": "^11.13.0",
"ava": "^1.4.1",
"get-stream": "^4.1.0",
"tsd": "^0.7.2",
"@types/node": "^12.7.5",
"ava": "^2.4.0",
"get-stream": "^5.1.0",
"tsd": "^0.8.0",
"xo": "^0.24.0"
}
}
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Text to display after the spinner.

Type: `string`

Text to display before the spinner. No prefix text will be displayed if set to empty string.
Text to display before the spinner. No prefix text will be displayed if set to an empty string.

##### spinner

Expand Down Expand Up @@ -181,7 +181,7 @@ Text to be persisted after the symbol
Type: `string`<br>
Default: Current `prefixText`

Text to be persisted before the symbol. No prefix text will be displayed if set to empty string.
Text to be persisted before the symbol. No prefix text will be displayed if set to an empty string.

<img src="screenshot-2.gif" width="480">

Expand All @@ -203,7 +203,7 @@ Change the text after the spinner.

#### .prefixText

Change the text before the spinner. No prefix text will be displayed if set to empty string.
Change the text before the spinner. No prefix text will be displayed if set to an empty string.

#### .color

Expand Down

0 comments on commit 6459090

Please sign in to comment.