From a6bb29ba4d78b9a813aa4fc2392c75995f54053b Mon Sep 17 00:00:00 2001 From: Lars Kappert Date: Wed, 1 Dec 2021 17:50:42 +0100 Subject: [PATCH] Downgrade chalk & migrate ora usage --- lib/spinner.js | 6 +++--- package.json | 2 +- test/spinner.js | 16 +++++++--------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/spinner.js b/lib/spinner.js index 4f80c645..fbbe70df 100644 --- a/lib/spinner.js +++ b/lib/spinner.js @@ -1,4 +1,4 @@ -import ora from 'ora'; +import { oraPromise } from 'ora'; import { format } from './util.js'; const noop = Promise.resolve(); @@ -6,7 +6,7 @@ const noop = Promise.resolve(); class Spinner { constructor({ container = {} } = {}) { this.config = container.config; - this.ora = container.ora || ora; + this.ora = container.ora || oraPromise; } show({ enabled = true, task, label, external = false, context }) { if (!enabled) return noop; @@ -19,7 +19,7 @@ class Spinner { if (!this.isSpinnerDisabled || (external && this.canForce)) { const text = format(label, context); - this.ora.promise(awaitTask, text); + this.ora(awaitTask, text); } return awaitTask; diff --git a/package.json b/package.json index 08205ed7..a6503b69 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "@iarna/toml": "2.2.5", "@octokit/rest": "18.12.0", "async-retry": "1.3.3", - "chalk": "5.0.0", + "chalk": "4.1.2", "cosmiconfig": "7.0.1", "debug": "4.3.3", "deprecated-obj": "2.0.0", diff --git a/test/spinner.js b/test/spinner.js index 0f460e15..3153bff9 100644 --- a/test/spinner.js +++ b/test/spinner.js @@ -4,9 +4,7 @@ import Spinner from '../lib/spinner.js'; import Config from '../lib/config.js'; test.beforeEach(t => { - t.context.ora = { - promise: sinon.spy() - }; + t.context.ora = sinon.spy(); }); const getConfig = options => { @@ -24,7 +22,7 @@ test('should not show spinner and not execute task if disabled', async t => { const spinner = new Spinner({ container: { ora } }); await spinner.show({ enabled: false, task }); t.is(task.callCount, 0); - t.is(ora.promise.callCount, 0); + t.is(ora.callCount, 0); }); test('should show spinner and run task by default', async t => { @@ -35,9 +33,9 @@ test('should show spinner and run task by default', async t => { const spinner = new Spinner({ container: { ora, config } }); await spinner.show({ task, label }); t.is(task.callCount, 1); - t.is(ora.promise.callCount, 1); - t.is(ora.promise.firstCall.args[0], task.firstCall.returnValue); - t.is(ora.promise.firstCall.args[1], label); + t.is(ora.callCount, 1); + t.is(ora.firstCall.args[0], task.firstCall.returnValue); + t.is(ora.firstCall.args[1], label); }); test('should run task, but not show spinner if interactive', async t => { @@ -47,7 +45,7 @@ test('should run task, but not show spinner if interactive', async t => { const spinner = new Spinner({ container: { ora, config } }); await spinner.show({ task }); t.is(task.callCount, 1); - t.is(ora.promise.callCount, 0); + t.is(ora.callCount, 0); }); test('should run task and show spinner if interactive, but external', async t => { @@ -57,5 +55,5 @@ test('should run task and show spinner if interactive, but external', async t => const spinner = new Spinner({ container: { ora, config } }); await spinner.show({ task, external: true }); t.is(task.callCount, 1); - t.is(ora.promise.callCount, 1); + t.is(ora.callCount, 1); });