Skip to content

Commit d61baf3

Browse files
committed
Don't assume local file (microsoft#36236)
1 parent cc2e278 commit d61baf3

1 file changed

Lines changed: 4 additions & 19 deletions

File tree

extensions/extension-editing/src/extensionLinter.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import * as fs from 'fs';
76
import * as path from 'path';
87

98
import * as nls from 'vscode-nls';
@@ -265,12 +264,12 @@ export class ExtensionLinter {
265264

266265
private async loadPackageJson(folder: Uri) {
267266
const file = folder.with({ path: path.posix.join(folder.path, 'package.json') });
268-
const exists = await fileExists(file.fsPath);
269-
if (!exists) {
267+
try {
268+
const document = await workspace.openTextDocument(file);
269+
return parseTree(document.getText());
270+
} catch (err) {
270271
return undefined;
271272
}
272-
const document = await workspace.openTextDocument(file);
273-
return parseTree(document.getText());
274273
}
275274

276275
private packageJsonChanged(folder: Uri) {
@@ -338,20 +337,6 @@ function endsWith(haystack: string, needle: string): boolean {
338337
}
339338
}
340339

341-
function fileExists(path: string): Promise<boolean> {
342-
return new Promise((resolve, reject) => {
343-
fs.lstat(path, (err, stats) => {
344-
if (!err) {
345-
resolve(true);
346-
} else if (err.code === 'ENOENT') {
347-
resolve(false);
348-
} else {
349-
reject(err);
350-
}
351-
});
352-
});
353-
}
354-
355340
function parseUri(src: string) {
356341
try {
357342
return Uri.parse(src);

0 commit comments

Comments
 (0)