From 1cda2dcd04cec203a0df166beb425d7a37379aeb Mon Sep 17 00:00:00 2001 From: zonemeen Date: Wed, 21 Feb 2024 10:36:44 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=B0=83=E6=95=B4=E6=9C=AA?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E6=AD=8C=E6=9B=B2=E6=8A=A5=E9=94=99=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/download.ts | 4 ++++ src/index.ts | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/download.ts b/src/download.ts index f58317dc4..da289b9e4 100644 --- a/src/download.ts +++ b/src/download.ts @@ -99,6 +99,10 @@ const downloadSong = (song: SongInfo, index: number) => { } const download = (songs: SongInfo[]) => { + if (!songs.length) { + console.error(red('请选择歌曲')) + process.exit(1) + } console.log(green('下载开始...')) multiBar.on('stop', () => { let errorMessage = '' diff --git a/src/index.ts b/src/index.ts index 236c0dd66..62197be9c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,3 @@ -import { red } from 'colorette' import command from './command' import choose from './choose' import searchMusic from './searchMusic' @@ -13,9 +12,5 @@ import type { SongInfo, CommandOptions } from './types' } const result = await searchMusic(command) const { songs = [] } = await choose(result) - if (!songs.length) { - console.error(red('请选择歌曲')) - process.exit(1) - } await download(songs) })()