feat(cli): print musescore-downloader version, msdl -v
This commit is contained in:
parent
04884a137f
commit
d33c06c892
2 changed files with 10 additions and 4 deletions
10
src/cli.ts
10
src/cli.ts
|
@ -10,7 +10,7 @@ import { loadMscore, INDV_DOWNLOADS, WebMscore } from './mscore'
|
||||||
import { ScoreInfo, ScoreInfoHtml, ScoreInfoObj, getActualId } from './scoreinfo'
|
import { ScoreInfo, ScoreInfoHtml, ScoreInfoObj, getActualId } from './scoreinfo'
|
||||||
import { getLibreScoreLink } from './librescore-link'
|
import { getLibreScoreLink } from './librescore-link'
|
||||||
import { escapeFilename } from './utils'
|
import { escapeFilename } from './utils'
|
||||||
import { isNpx, getVerInfo } from './npm-data'
|
import { isNpx, getVerInfo, getSelfVer } from './npm-data'
|
||||||
import i18n from './i18n'
|
import i18n from './i18n'
|
||||||
|
|
||||||
const inquirer: typeof import('inquirer') = require('inquirer')
|
const inquirer: typeof import('inquirer') = require('inquirer')
|
||||||
|
@ -30,6 +30,12 @@ interface Params {
|
||||||
}
|
}
|
||||||
|
|
||||||
void (async () => {
|
void (async () => {
|
||||||
|
const arg = process.argv[2]
|
||||||
|
if (['-v', '--version'].includes(arg)) { // ran with flag -v or --version, `msdl -v`
|
||||||
|
console.log(getSelfVer()) // print musescore-downloader version
|
||||||
|
return // exit process
|
||||||
|
}
|
||||||
|
|
||||||
// Determine platform and paste message
|
// Determine platform and paste message
|
||||||
const platform = os.platform()
|
const platform = os.platform()
|
||||||
let pasteMessage = ''
|
let pasteMessage = ''
|
||||||
|
@ -56,7 +62,7 @@ void (async () => {
|
||||||
(input.endsWith(EXT) && fs.statSync(input).isFile())
|
(input.endsWith(EXT) && fs.statSync(input).isFile())
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
default: process.argv[2],
|
default: arg,
|
||||||
})
|
})
|
||||||
|
|
||||||
const isLocalFile = fileInit.endsWith(EXT)
|
const isLocalFile = fileInit.endsWith(EXT)
|
||||||
|
|
|
@ -12,7 +12,7 @@ export function isNpx (): boolean {
|
||||||
return __dirname.match(IS_NPX_REG) !== null
|
return __dirname.match(IS_NPX_REG) !== null
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getInstalledVer (): string {
|
export function getSelfVer (): string {
|
||||||
return pkgVer
|
return pkgVer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ export async function getLatestVer (_fetch = getFetch()): Promise<string> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getVerInfo () {
|
export async function getVerInfo () {
|
||||||
const installed = getInstalledVer()
|
const installed = getSelfVer()
|
||||||
const latest = await getLatestVer()
|
const latest = await getLatestVer()
|
||||||
return {
|
return {
|
||||||
installed,
|
installed,
|
||||||
|
|
Loading…
Reference in a new issue