Skip to content

Commit 9b22377

Browse files
committed
chore(vscode): ignore typescript package json missing error
1 parent 9965d56 commit 9b22377

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

extensions/vscode/src/common.ts

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -130,28 +130,29 @@ function getCurrentHybridModeStatus(report = false) {
130130
}
131131

132132
function getTsVersion(libPath: string): string | undefined {
133-
134-
const p = libPath.toString().split('/');
135-
const p2 = p.slice(0, -1);
136-
const modulePath = p2.join('/');
137-
const filePath = modulePath + '/package.json';
138-
const contents = fs.readFileSync(filePath, 'utf-8');
139-
140-
if (contents === undefined) {
141-
return;
142-
}
143-
144-
let desc: any = null;
145133
try {
146-
desc = JSON.parse(contents);
147-
} catch (err) {
148-
return;
149-
}
150-
if (!desc || !desc.version) {
151-
return;
152-
}
134+
const p = libPath.toString().split('/');
135+
const p2 = p.slice(0, -1);
136+
const modulePath = p2.join('/');
137+
const filePath = modulePath + '/package.json';
138+
const contents = fs.readFileSync(filePath, 'utf-8');
139+
140+
if (contents === undefined) {
141+
return;
142+
}
143+
144+
let desc: any = null;
145+
try {
146+
desc = JSON.parse(contents);
147+
} catch (err) {
148+
return;
149+
}
150+
if (!desc || !desc.version) {
151+
return;
152+
}
153153

154-
return desc.version;
154+
return desc.version;
155+
} catch { }
155156
}
156157
}
157158

0 commit comments

Comments
 (0)