Skip to content

Commit

Permalink
chore(vscode): ignore typescript package json missing error
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Apr 4, 2024
1 parent 9965d56 commit 9b22377
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions extensions/vscode/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,28 +130,29 @@ function getCurrentHybridModeStatus(report = false) {
}

function getTsVersion(libPath: string): string | undefined {

const p = libPath.toString().split('/');
const p2 = p.slice(0, -1);
const modulePath = p2.join('/');
const filePath = modulePath + '/package.json';
const contents = fs.readFileSync(filePath, 'utf-8');

if (contents === undefined) {
return;
}

let desc: any = null;
try {
desc = JSON.parse(contents);
} catch (err) {
return;
}
if (!desc || !desc.version) {
return;
}
const p = libPath.toString().split('/');
const p2 = p.slice(0, -1);
const modulePath = p2.join('/');
const filePath = modulePath + '/package.json';
const contents = fs.readFileSync(filePath, 'utf-8');

if (contents === undefined) {
return;
}

let desc: any = null;
try {
desc = JSON.parse(contents);
} catch (err) {
return;
}
if (!desc || !desc.version) {
return;
}

return desc.version;
return desc.version;
} catch { }
}
}

Expand Down

0 comments on commit 9b22377

Please sign in to comment.