Skip to content

Commit

Permalink
Resolve MOPS from local package.json dependencies (#147)
Browse files Browse the repository at this point in the history
* Resolve 'ic-mops' npm package instead of global 'mops' binary

* Improve error handling for missing MOPS or Vessel installation

* Detect global 'ic-mops'

* 0.7.3

* Clarify possible MOPS installation locations in error message
  • Loading branch information
rvanasa committed Jan 8, 2023
1 parent 7a03b92 commit e2ce028
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-motoko",
"displayName": "Motoko",
"description": "Motoko language support",
"version": "0.7.2",
"version": "0.7.3",
"publisher": "dfinity-foundation",
"repository": "https://github.com/dfinity/vscode-motoko",
"engines": {
Expand Down
15 changes: 11 additions & 4 deletions src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ async function getPackageSources(

// Prioritize MOPS over Vessel
if (existsSync(join(directory, 'mops.toml'))) {
const command = 'mops sources';
// const command = 'mops sources';
const command = 'npx --no ic-mops sources';
try {
return sourcesFromCommand(command);
} catch (err: any) {
Expand All @@ -125,15 +126,21 @@ async function getPackageSources(
// }

throw new Error(
`Error while running \`${command}\`: ${err?.message || err}`,
`Error while finding MOPS packages.\nMake sure MOPS is installed locally or globally (https://mops.one/docs/install).\n${
err?.message || err
}`,
);
}
} else if (existsSync(join(directory, 'vessel.dhall'))) {
const command = 'vessel sources';
try {
return sourcesFromCommand(command);
} catch (err) {
console.error(`Error while running \`${command}\`:`, err);
} catch (err: any) {
console.error(
`Error while running \`${command}\`.\nMake sure Vessel is installed (https://github.com/dfinity/vessel/#getting-started).\n${
err?.message || err
}`,
);
return vesselSources(directory);
}
} else {
Expand Down

0 comments on commit e2ce028

Please sign in to comment.