Skip to content

Commit 7da9fe1

Browse files
authored
refactor: replace ora with nanospinner (#699)
1 parent 7924f38 commit 7da9fe1

File tree

3 files changed

+21
-71
lines changed

3 files changed

+21
-71
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"clean-css": "^5.3.3",
6868
"fast-glob": "^3.3.3",
6969
"magic-string": "^0.30.17",
70-
"ora": "^8.0.1",
70+
"nanospinner": "^1.2.2",
7171
"picomatch": "^4.0.2",
7272
"pretty-bytes": "^5.6.0",
7373
"rollup": "^4.46.2",

pnpm-lock.yaml

Lines changed: 10 additions & 58 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bin/index.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { prepare } from '../prepare'
1212
import { RollupWatcher } from 'rollup'
1313
import { logOutputState } from '../plugins/output-state-plugin'
1414
import { normalizeError } from '../lib/normalize-error'
15+
import { createSpinner } from 'nanospinner'
1516

1617
const helpMessage = `
1718
Usage: bunchee [options]
@@ -258,18 +259,15 @@ async function run(args: CliArgs) {
258259
// lint package by default
259260
await lint(cwd)
260261

261-
const { default: ora } = await import('ora')
262-
263-
const oraInstance = process.stdout.isTTY
264-
? ora({
265-
text: 'Building...\n\n',
262+
const spinnerInstance = process.stdout.isTTY
263+
? createSpinner('Building...\n\n', {
266264
color: 'green',
267265
})
268266
: {
269267
start: () => {},
270268
stop: () => {},
271269
clear: () => {},
272-
stopAndPersist: () => {},
270+
success: () => {},
273271
isSpinning: false,
274272
}
275273

@@ -279,19 +277,19 @@ async function run(args: CliArgs) {
279277
}
280278

281279
function startSpinner() {
282-
oraInstance.start()
280+
spinnerInstance.start()
283281
}
284282

285283
function stopSpinner(text?: string) {
286-
if (oraInstance.isSpinning) {
287-
oraInstance.clear()
284+
if (spinnerInstance.isSpinning) {
285+
spinnerInstance.clear()
288286
if (text) {
289-
oraInstance.stopAndPersist({
290-
symbol: '✔',
287+
spinnerInstance.success({
288+
mark: '✔',
291289
text,
292290
})
293291
} else {
294-
oraInstance.stop()
292+
spinnerInstance.stop()
295293
}
296294
}
297295
}

0 commit comments

Comments
 (0)