提交 d61baf3b 编写于 作者: C Christof Marti

Don't assume local file (#36236)

上级 cc2e2781
......@@ -3,7 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as fs from 'fs';
import * as path from 'path';
import * as nls from 'vscode-nls';
......@@ -265,12 +264,12 @@ export class ExtensionLinter {
private async loadPackageJson(folder: Uri) {
const file = folder.with({ path: path.posix.join(folder.path, 'package.json') });
const exists = await fileExists(file.fsPath);
if (!exists) {
try {
const document = await workspace.openTextDocument(file);
return parseTree(document.getText());
} catch (err) {
return undefined;
}
const document = await workspace.openTextDocument(file);
return parseTree(document.getText());
}
private packageJsonChanged(folder: Uri) {
......@@ -338,20 +337,6 @@ function endsWith(haystack: string, needle: string): boolean {
}
}
function fileExists(path: string): Promise<boolean> {
return new Promise((resolve, reject) => {
fs.lstat(path, (err, stats) => {
if (!err) {
resolve(true);
} else if (err.code === 'ENOENT') {
resolve(false);
} else {
reject(err);
}
});
});
}
function parseUri(src: string) {
try {
return Uri.parse(src);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册