Skip to content

Commit

Permalink
Improve vessel sources error handling (#121)
Browse files Browse the repository at this point in the history
* Improve 'vessel sources' error handling

* 0.6.1
  • Loading branch information
rvanasa authored Dec 9, 2022
1 parent ad0582c commit 3e7a6c1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion 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.6.0",
"version": "0.6.1",
"publisher": "dfinity-foundation",
"repository": "https://github.com/dfinity/vscode-motoko",
"engines": {
Expand Down
38 changes: 19 additions & 19 deletions src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,28 @@ const ignoreGlobs = [
];

function getVesselSources(directory: string): [string, string][] {
if (!existsSync('vessel')) {
// Fallback Vessel functionality
return vesselSources(directory);
}

const flags = execSync('vessel sources', {
cwd: directory,
}).toString('utf8');
const args = flags.split(' ');
const sources: [string, string][] = [];
let nextArg;
while ((nextArg = args.shift())) {
if (nextArg === '--package') {
const name = args.shift()!;
const relativePath = args.shift();
if (!relativePath) {
continue;
try {
const flags = execSync('vessel sources', {
cwd: directory,
}).toString('utf8');
const args = flags.split(' ');
const sources: [string, string][] = [];
let nextArg;
while ((nextArg = args.shift())) {
if (nextArg === '--package') {
const name = args.shift()!;
const relativePath = args.shift();
if (!relativePath) {
continue;
}
sources.push([name, relativePath]);
}
sources.push([name, relativePath]);
}
return sources;
} catch (err) {
console.error('Error while running `vessel sources`:', err);
return vesselSources(directory);
}
return sources;
}

let vesselChangeTimeout: ReturnType<typeof setTimeout>;
Expand Down

0 comments on commit 3e7a6c1

Please sign in to comment.