Skip to content

Commit

Permalink
Throw better error if adding non-existent package
Browse files Browse the repository at this point in the history
Throw an error that says the package doesn't exist, instead of a JSON parsing error
  • Loading branch information
lhorie authored and fusionjs-sync-bot[bot] committed Apr 17, 2020
1 parent 4981ae7 commit fcca3a2
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions jazelle/utils/lockfile.js
Expand Up @@ -336,10 +336,16 @@ const ensureInsertionRanges = async insertions => {
await Promise.all(
insertions.map(async insertion => {
if (!insertion.range) {
const cmd = `yarn info ${insertion.name} version --json`;
const info = await exec(cmd, {env: process.env});
const {data} = JSON.parse(info);
insertion.range = `^${data}`; // eslint-disable-line require-atomic-updates
try {
const cmd = `yarn info ${insertion.name} version --json`;
const info = await exec(cmd, {env: process.env});
const {data} = JSON.parse(info);
insertion.range = `^${data}`; // eslint-disable-line require-atomic-updates
} catch (e) {
throw new Error(
`Package ${insertion.name} does not exist in NPM registry`
);
}
}
})
);
Expand Down

0 comments on commit fcca3a2

Please sign in to comment.