Skip to content

Commit

Permalink
refactor: 调整未选择歌曲报错位置
Browse files Browse the repository at this point in the history
  • Loading branch information
zonemeen committed Feb 21, 2024
1 parent 84923fc commit 1cda2dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down
5 changes: 0 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { red } from 'colorette'
import command from './command'
import choose from './choose'
import searchMusic from './searchMusic'
Expand All @@ -13,9 +12,5 @@ import type { SongInfo, CommandOptions } from './types'
}
const result = await searchMusic(<SongInfo>command)
const { songs = [] } = await choose(<SongInfo>result)
if (!songs.length) {
console.error(red('请选择歌曲'))
process.exit(1)
}
await download(songs)
})()

0 comments on commit 1cda2dc

Please sign in to comment.