musescore-downloader/src/npm-data.ts

23 lines
622 B
TypeScript
Raw Normal View History

import { exec as _exec } from 'child_process'
import { promisify } from 'util'
2021-01-20 15:52:08 +00:00
import { version } from '../package.json'
const exec = promisify(_exec)
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')
return output.stdout.includes('(empty)')
}
2021-01-20 15:52:08 +00:00
export function getInstalledVer (): string {
return version
}
2021-01-20 15:52:08 +00:00
export async function getLatestVer (): Promise<string> {
return (await exec('npm info musescore-downloader version')).stdout.trim()
}
2021-01-20 15:52:08 +00:00
export function isLatest (installed: string, lastest: string): boolean {
return installed === lastest
}