mirror of
https://github.com/Microsoft/vscode
synced 2024-10-02 17:32:41 +00:00
Merge pull request #124803 from nrayburn-tech/npm-activation
npm extension - check for root package.json before findFiles
This commit is contained in:
commit
ba5f685b65
|
@ -363,12 +363,16 @@ export function getPackageJsonUriFromTask(task: Task): Uri | null {
|
|||
}
|
||||
|
||||
export async function hasPackageJson(): Promise<boolean> {
|
||||
// Faster than `findFiles` for workspaces with a root package.json.
|
||||
if (await hasRootPackageJson()) {
|
||||
return true;
|
||||
}
|
||||
const token = new CancellationTokenSource();
|
||||
// Search for files for max 1 second.
|
||||
const timeout = setTimeout(() => token.cancel(), 1000);
|
||||
const files = await workspace.findFiles('**/package.json', undefined, 1, token.token);
|
||||
clearTimeout(timeout);
|
||||
return files.length > 0 || await hasRootPackageJson();
|
||||
return files.length > 0;
|
||||
}
|
||||
|
||||
async function hasRootPackageJson(): Promise<boolean> {
|
||||
|
|
Loading…
Reference in a new issue