fix: packages and unnecessary if statement

This commit is contained in:
Peter Njeim 2021-03-12 19:35:41 -04:00
parent 3260672412
commit 6a6e2a5ea1
4 changed files with 7772 additions and 5253 deletions

13016
dist/main.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -88,7 +88,7 @@ void (async () => {
if (!confirmed) return if (!confirmed) return
// initiate LibreScore link request // initiate LibreScore link request
librescoreLink = getLibreScoreLink(scoreinfo) librescoreLink = getLibreScoreLink(scoreinfo, true)
// print a blank line to the terminal // print a blank line to the terminal
console.log() console.log()
@ -133,6 +133,7 @@ void (async () => {
spinner.info('Score loaded by webmscore') spinner.info('Score loaded by webmscore')
} catch (err) { } catch (err) {
spinner.fail(err.message) spinner.fail(err.message)
spinner.info('Send your URL to the #dataset-bugs channel in the LibreScore Community Discord server');
return return
} }
spinner.succeed('OK\n') spinner.succeed('OK\n')

View File

@ -6,7 +6,7 @@ const _getLink = (scorepack: string) => {
return `https://librescore.org/score/${scorepack}` return `https://librescore.org/score/${scorepack}`
} }
export const getLibreScoreLink = async (scoreinfo: ScoreInfo, _fetch = getFetch()): Promise<string> => { export const getLibreScoreLink = async (scoreinfo: ScoreInfo, isMsdl: Boolean, _fetch = getFetch()): Promise<string> => {
const mainCid = await getMainCid(scoreinfo, _fetch) const mainCid = await getMainCid(scoreinfo, _fetch)
const ref = scoreinfo.getScorepackRef(mainCid) const ref = scoreinfo.getScorepackRef(mainCid)
const url = `https://ipfs.infura.io:5001/api/v0/dag/get?arg=${ref}` const url = `https://ipfs.infura.io:5001/api/v0/dag/get?arg=${ref}`
@ -16,7 +16,7 @@ export const getLibreScoreLink = async (scoreinfo: ScoreInfo, _fetch = getFetch(
assertRes(r0) assertRes(r0)
} }
const res: { Message: string } | string = await r0.json() const res: { Message: string } | string = await r0.json()
if (typeof res !== 'string') { if (typeof res !== 'string' && !isMsdl) {
// read further error msg // read further error msg
throw new Error(res.Message) throw new Error(res.Message)
} }

View File

@ -48,7 +48,7 @@ export const loadMsczUrl = async (scoreinfo: ScoreInfo, _fetch = getFetch()): Pr
// read further error msg // read further error msg
const err = cidRes.Message const err = cidRes.Message
if (err.includes('no link named')) { // file not found if (err.includes('no link named')) { // file not found
throw new Error('score not in dataset') throw new Error('Score not in dataset')
} else { } else {
throw new Error(err) throw new Error(err)
} }