2021-01-20 16:05:56 +00:00
|
|
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
|
|
|
2021-01-15 08:06:31 +00:00
|
|
|
import { exec as _exec } from 'child_process'
|
|
|
|
import { promisify } from 'util'
|
2021-01-20 15:52:08 +00:00
|
|
|
import { version } from '../package.json'
|
2021-01-15 07:54:01 +00:00
|
|
|
|
2021-01-15 08:06:31 +00:00
|
|
|
const exec = promisify(_exec)
|
2021-01-15 07:54:01 +00:00
|
|
|
|
2021-01-20 15:52:08 +00:00
|
|
|
export async function isNpx (): Promise<boolean> {
|
2021-01-15 07:55:06 +00:00
|
|
|
const output = await exec('npm list -g musescore-downloader')
|
2021-01-15 08:06:31 +00:00
|
|
|
return output.stdout.includes('(empty)')
|
2021-01-15 07:54:01 +00:00
|
|
|
}
|
|
|
|
|
2021-01-20 15:52:08 +00:00
|
|
|
export function getInstalledVer (): string {
|
|
|
|
return version
|
2021-01-15 08:01:11 +00:00
|
|
|
}
|
2021-01-15 07:54:01 +00:00
|
|
|
|
2021-01-20 15:52:08 +00:00
|
|
|
export async function getLatestVer (): Promise<string> {
|
2021-01-15 08:01:11 +00:00
|
|
|
return (await exec('npm info musescore-downloader version')).stdout.trim()
|
|
|
|
}
|
|
|
|
|
2021-01-20 16:05:56 +00:00
|
|
|
export async function getVerInfo () {
|
|
|
|
const installed = getInstalledVer()
|
|
|
|
const latest = await getLatestVer()
|
|
|
|
return {
|
|
|
|
installed,
|
|
|
|
latest,
|
|
|
|
isLatest: installed === latest,
|
|
|
|
}
|
2021-01-20 15:42:33 +00:00
|
|
|
}
|