mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
fix bad localize usage of localize
This commit is contained in:
parent
efcc4fb223
commit
d1870a4018
|
@ -6,9 +6,6 @@
|
|||
|
||||
import * as httpRequest from 'request-light';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
import { addJSONProviders } from './features/jsonContributions';
|
||||
import { NpmScriptsTreeDataProvider } from './npmView';
|
||||
|
@ -27,7 +24,7 @@ function registerTaskProvider(context: vscode.ExtensionContext): vscode.Disposab
|
|||
if (vscode.workspace.workspaceFolders) {
|
||||
let provider: vscode.TaskProvider = {
|
||||
provideTasks: () => {
|
||||
return provideNpmScripts(localize);
|
||||
return provideNpmScripts();
|
||||
},
|
||||
resolveTask(_task: vscode.Task): vscode.Task | undefined {
|
||||
return undefined;
|
||||
|
@ -42,7 +39,7 @@ function registerTaskProvider(context: vscode.ExtensionContext): vscode.Disposab
|
|||
|
||||
async function registerExplorer(context: vscode.ExtensionContext, provider: vscode.TaskProvider) {
|
||||
if (explorerIsEnabled()) {
|
||||
let treeDataProvider = vscode.window.registerTreeDataProvider('npm', new NpmScriptsTreeDataProvider(context, provider, localize));
|
||||
let treeDataProvider = vscode.window.registerTreeDataProvider('npm', new NpmScriptsTreeDataProvider(context, provider));
|
||||
context.subscriptions.push(treeDataProvider);
|
||||
if (await hasNpmScripts()) {
|
||||
vscode.commands.executeCommand('setContext', 'hasNpmScripts', true);
|
||||
|
|
|
@ -12,6 +12,9 @@ import {
|
|||
} from 'vscode';
|
||||
import { visit, JSONVisitor } from 'jsonc-parser';
|
||||
import { NpmTaskDefinition, getPackageJsonUriFromTask, getScripts, isWorkspaceFolder, getPackageManager, getTaskName } from './tasks';
|
||||
import * as nls from 'vscode-nls';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
class Folder extends TreeItem {
|
||||
packages: PackageJSON[] = [];
|
||||
|
@ -90,15 +93,13 @@ class NpmScript extends TreeItem {
|
|||
export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
|
||||
private taskTree: Folder[] | PackageJSON[] | null = null;
|
||||
private taskProvider: TaskProvider;
|
||||
private localize: any;
|
||||
private extensionContext: ExtensionContext;
|
||||
private _onDidChangeTreeData: EventEmitter<TreeItem | null> = new EventEmitter<TreeItem | null>();
|
||||
readonly onDidChangeTreeData: Event<TreeItem | null> = this._onDidChangeTreeData.event;
|
||||
|
||||
constructor(context: ExtensionContext, taskProvider: TaskProvider, localize: any) {
|
||||
constructor(context: ExtensionContext, taskProvider: TaskProvider) {
|
||||
const subscriptions = context.subscriptions;
|
||||
this.taskProvider = taskProvider;
|
||||
this.localize = localize;
|
||||
this.extensionContext = context;
|
||||
subscriptions.push(commands.registerCommand('npm.runScript', this.runScript, this));
|
||||
subscriptions.push(commands.registerCommand('npm.debugScript', this.debugScript, this));
|
||||
|
@ -119,7 +120,7 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
|
|||
private async runScript(script: NpmScript) {
|
||||
let task = script.task;
|
||||
let uri = getPackageJsonUriFromTask(task);
|
||||
let scripts = await getScripts(uri!, this.localize);
|
||||
let scripts = await getScripts(uri!);
|
||||
|
||||
if (!this.scriptIsValid(scripts, task)) {
|
||||
this.scriptNotValid(task);
|
||||
|
@ -149,7 +150,7 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
|
|||
private async debugScript(script: NpmScript) {
|
||||
let task = script.task;
|
||||
let uri = getPackageJsonUriFromTask(task);
|
||||
let scripts = await getScripts(uri!, this.localize);
|
||||
let scripts = await getScripts(uri!);
|
||||
|
||||
if (!this.scriptIsValid(scripts, task)) {
|
||||
this.scriptNotValid(task);
|
||||
|
@ -158,7 +159,7 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
|
|||
|
||||
let debugArg = await this.extractDebugArg(scripts, task);
|
||||
if (!debugArg) {
|
||||
let message = this.localize('npm.noDebugOptions', 'Could not launch "{0}" for debugging, the script needs to include the node debug options: "--nolazy --inspect-brk=port", [learn more](https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_launch-configuration-support-for-npm-and-other-tools).', task.name);
|
||||
let message = localize('npm.noDebugOptions', 'Could not launch "{0}" for debugging, the script needs to include the node debug options: "--nolazy --inspect-brk=port", [learn more](https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_launch-configuration-support-for-npm-and-other-tools).', task.name);
|
||||
window.showErrorMessage(message);
|
||||
return;
|
||||
}
|
||||
|
@ -182,7 +183,7 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
|
|||
}
|
||||
|
||||
private scriptNotValid(task: Task) {
|
||||
let message = this.localize('npm.scriptInvalid', 'Could not find the script "{0}". Try to refresh the view.', task.name);
|
||||
let message = localize('npm.scriptInvalid', 'Could not find the script "{0}". Try to refresh the view.', task.name);
|
||||
window.showErrorMessage(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@ import { TaskDefinition, Task, TaskGroup, WorkspaceFolder, RelativePattern, Shel
|
|||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import * as minimatch from 'minimatch';
|
||||
import * as nls from 'vscode-nls';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
export interface NpmTaskDefinition extends TaskDefinition {
|
||||
script: string;
|
||||
|
@ -84,7 +87,7 @@ export async function hasNpmScripts(): Promise<boolean> {
|
|||
}
|
||||
}
|
||||
|
||||
export async function provideNpmScripts(localize: any): Promise<Task[]> {
|
||||
export async function provideNpmScripts(): Promise<Task[]> {
|
||||
let emptyTasks: Task[] = [];
|
||||
let allTasks: Task[] = [];
|
||||
|
||||
|
@ -100,7 +103,7 @@ export async function provideNpmScripts(localize: any): Promise<Task[]> {
|
|||
let paths = await workspace.findFiles(relativePattern, '**/node_modules/**');
|
||||
for (let j = 0; j < paths.length; j++) {
|
||||
if (!isExcluded(folder, paths[j])) {
|
||||
let tasks = await provideNpmScriptsForFolder(localize, paths[j]);
|
||||
let tasks = await provideNpmScriptsForFolder(paths[j]);
|
||||
allTasks.push(...tasks);
|
||||
}
|
||||
}
|
||||
|
@ -137,14 +140,14 @@ function isExcluded(folder: WorkspaceFolder, packageJsonUri: Uri) {
|
|||
return false;
|
||||
}
|
||||
|
||||
async function provideNpmScriptsForFolder(localize: any, packageJsonUri: Uri): Promise<Task[]> {
|
||||
async function provideNpmScriptsForFolder(packageJsonUri: Uri): Promise<Task[]> {
|
||||
let emptyTasks: Task[] = [];
|
||||
|
||||
let folder = workspace.getWorkspaceFolder(packageJsonUri);
|
||||
if (!folder) {
|
||||
return emptyTasks;
|
||||
}
|
||||
let scripts = await getScripts(packageJsonUri, localize);
|
||||
let scripts = await getScripts(packageJsonUri);
|
||||
if (!scripts) {
|
||||
return emptyTasks;
|
||||
}
|
||||
|
@ -232,7 +235,7 @@ async function readFile(file: string): Promise<string> {
|
|||
});
|
||||
}
|
||||
|
||||
export async function getScripts(packageJsonUri: Uri, localize: any): Promise<any> {
|
||||
export async function getScripts(packageJsonUri: Uri): Promise<any> {
|
||||
|
||||
if (packageJsonUri.scheme !== 'file') {
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue