mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 13:29:44 +00:00
parent
690c76c105
commit
f38f90dfe1
|
@ -370,7 +370,23 @@ export async function hasPackageJson(): Promise<boolean> {
|
|||
const timeout = setTimeout(() => token.cancel(), 1000);
|
||||
const files = await workspace.findFiles('**/package.json', undefined, 1, token.token);
|
||||
clearTimeout(timeout);
|
||||
return files.length > 0;
|
||||
return files.length > 0 || await hasRootPackageJson();
|
||||
}
|
||||
|
||||
async function hasRootPackageJson(): Promise<boolean> {
|
||||
let folders = workspace.workspaceFolders;
|
||||
if (!folders) {
|
||||
return false;
|
||||
}
|
||||
for (const folder of folders) {
|
||||
if (folder.uri.scheme === 'file') {
|
||||
let packageJson = path.join(folder.uri.fsPath, 'package.json');
|
||||
if (await exists(packageJson)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
async function exists(file: string): Promise<boolean> {
|
||||
|
|
Loading…
Reference in a new issue