chore(vscode): update to 1.55.2
This commit is contained in:
@ -8,7 +8,7 @@ import * as vscode from 'vscode';
|
||||
import { addJSONProviders } from './features/jsonContributions';
|
||||
import { runSelectedScript, selectAndRunScriptFromFolder } from './commands';
|
||||
import { NpmScriptsTreeDataProvider } from './npmView';
|
||||
import { getPackageManager, invalidateTasksCache, NpmTaskProvider } from './tasks';
|
||||
import { getPackageManager, invalidateTasksCache, NpmTaskProvider, hasPackageJson } from './tasks';
|
||||
import { invalidateHoverScriptsCache, NpmScriptHoverProvider } from './scriptHover';
|
||||
import { NpmScriptLensProvider } from './npmScriptLens';
|
||||
|
||||
@ -53,6 +53,11 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
|
||||
registerHoverProvider(context);
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('npm.runSelectedScript', runSelectedScript));
|
||||
|
||||
if (await hasPackageJson()) {
|
||||
vscode.commands.executeCommand('setContext', 'npm:showScriptExplorer', true);
|
||||
}
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('npm.runScriptFromFolder', selectAndRunScriptFromFolder));
|
||||
context.subscriptions.push(vscode.commands.registerCommand('npm.refresh', () => {
|
||||
invalidateScriptCaches();
|
||||
|
@ -6,7 +6,7 @@
|
||||
import {
|
||||
TaskDefinition, Task, TaskGroup, WorkspaceFolder, RelativePattern, ShellExecution, Uri, workspace,
|
||||
TaskProvider, TextDocument, tasks, TaskScope, QuickPickItem, window, Position, ExtensionContext, env,
|
||||
ShellQuotedString, ShellQuoting, commands, Location
|
||||
ShellQuotedString, ShellQuoting, commands, Location, CancellationTokenSource
|
||||
} from 'vscode';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
@ -365,19 +365,12 @@ export function getPackageJsonUriFromTask(task: Task): Uri | null {
|
||||
}
|
||||
|
||||
export async function hasPackageJson(): 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;
|
||||
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;
|
||||
}
|
||||
|
||||
async function exists(file: string): Promise<boolean> {
|
||||
|
Reference in New Issue
Block a user