Onboard npm to use shared tsconfig
This commit is contained in:
parent
6769079c0d
commit
936742b5d1
7 changed files with 13 additions and 25 deletions
|
@ -5,7 +5,7 @@
|
|||
'use strict';
|
||||
|
||||
import { MarkedString, CompletionItemKind, CompletionItem, DocumentSelector, SnippetString, workspace } from 'vscode';
|
||||
import { IJSONContribution, ISuggestionsCollector, xhrDisabled } from './jsonContributions';
|
||||
import { IJSONContribution, ISuggestionsCollector } from './jsonContributions';
|
||||
import { XHRRequest } from 'request-light';
|
||||
import { Location } from 'jsonc-parser';
|
||||
import { textToMarkedString } from './markedTextUtil';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
'use strict';
|
||||
|
||||
import { MarkedString, CompletionItemKind, CompletionItem, DocumentSelector, SnippetString, workspace } from 'vscode';
|
||||
import { IJSONContribution, ISuggestionsCollector, xhrDisabled } from './jsonContributions';
|
||||
import { IJSONContribution, ISuggestionsCollector } from './jsonContributions';
|
||||
import { XHRRequest } from 'request-light';
|
||||
import { Location } from 'jsonc-parser';
|
||||
import { textToMarkedString } from './markedTextUtil';
|
||||
|
|
|
@ -13,9 +13,9 @@ import { invalidateHoverScriptsCache, NpmScriptHoverProvider } from './scriptHov
|
|||
import { runSelectedScript } from './commands';
|
||||
|
||||
export async function activate(context: vscode.ExtensionContext): Promise<void> {
|
||||
const taskProvider = registerTaskProvider(context);
|
||||
registerTaskProvider(context);
|
||||
const treeDataProvider = registerExplorer(context);
|
||||
const hoverProvider = registerHoverProvider(context);
|
||||
registerHoverProvider(context);
|
||||
|
||||
configureHttpRequest();
|
||||
let d = vscode.workspace.onDidChangeConfiguration((e) => {
|
||||
|
@ -59,7 +59,7 @@ function registerTaskProvider(context: vscode.ExtensionContext): vscode.Disposab
|
|||
let workspaceWatcher = vscode.workspace.onDidChangeWorkspaceFolders((_e) => invalidateScriptCaches());
|
||||
context.subscriptions.push(workspaceWatcher);
|
||||
|
||||
let provider: vscode.TaskProvider = new NpmTaskProvider(context);
|
||||
let provider: vscode.TaskProvider = new NpmTaskProvider();
|
||||
let disposable = vscode.workspace.registerTaskProvider('npm', provider);
|
||||
context.subscriptions.push(disposable);
|
||||
return disposable;
|
||||
|
|
|
@ -43,7 +43,7 @@ class PackageJSON extends TreeItem {
|
|||
folder: Folder;
|
||||
scripts: NpmScript[] = [];
|
||||
|
||||
static getLabel(folderName: string, relativePath: string): string {
|
||||
static getLabel(_folderName: string, relativePath: string): string {
|
||||
if (relativePath.length > 0) {
|
||||
return path.join(relativePath, packageName);
|
||||
}
|
||||
|
@ -338,7 +338,6 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
|
|||
folder.addPackage(packageJson);
|
||||
packages.set(fullPath, packageJson);
|
||||
}
|
||||
let fullScriptPath = path.join(packageJson.path, each.name);
|
||||
let script = new NpmScript(this.extensionContext, packageJson, each);
|
||||
packageJson.addScript(script);
|
||||
}
|
||||
|
|
|
@ -29,10 +29,8 @@ export function invalidateHoverScriptsCache(document?: TextDocument) {
|
|||
}
|
||||
|
||||
export class NpmScriptHoverProvider implements HoverProvider {
|
||||
private extensionContext: ExtensionContext;
|
||||
|
||||
constructor(context: ExtensionContext) {
|
||||
this.extensionContext = context;
|
||||
context.subscriptions.push(commands.registerCommand('npm.runScriptFromHover', this.runScriptFromHover, this));
|
||||
context.subscriptions.push(commands.registerCommand('npm.debugScriptFromHover', this.debugScriptFromHover, this));
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import {
|
||||
TaskDefinition, Task, TaskGroup, WorkspaceFolder, RelativePattern, ShellExecution, Uri, workspace,
|
||||
DebugConfiguration, debug, TaskProvider, ExtensionContext, TextDocument, tasks
|
||||
DebugConfiguration, debug, TaskProvider, TextDocument, tasks
|
||||
} from 'vscode';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
|
@ -26,10 +26,8 @@ type AutoDetect = 'on' | 'off';
|
|||
let cachedTasks: Task[] | undefined = undefined;
|
||||
|
||||
export class NpmTaskProvider implements TaskProvider {
|
||||
private extensionContext: ExtensionContext;
|
||||
|
||||
constructor(context: ExtensionContext) {
|
||||
this.extensionContext = context;
|
||||
constructor() {
|
||||
}
|
||||
|
||||
public provideTasks() {
|
||||
|
@ -373,7 +371,7 @@ async function findAllScripts(buffer: string): Promise<StringMap> {
|
|||
}
|
||||
else if (inScripts && !script) {
|
||||
script = property;
|
||||
} else { // nested object which is invalid, ignore the script
|
||||
} else { // nested object which is invalid, ignore the script
|
||||
script = undefined;
|
||||
}
|
||||
}
|
||||
|
@ -444,14 +442,14 @@ export function findScriptAtPosition(buffer: string, offset: number): string | u
|
|||
}
|
||||
}
|
||||
},
|
||||
onObjectProperty(property: string, nodeOffset: number, nodeLength: number) {
|
||||
onObjectProperty(property: string, nodeOffset: number) {
|
||||
if (property === 'scripts') {
|
||||
inScripts = true;
|
||||
}
|
||||
else if (inScripts) {
|
||||
scriptStart = nodeOffset;
|
||||
script = property;
|
||||
} else { // nested object which is invalid, ignore the script
|
||||
} else { // nested object which is invalid, ignore the script
|
||||
script = undefined;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,7 @@
|
|||
{
|
||||
"extends": "../shared.tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es2016"
|
||||
],
|
||||
"outDir": "./out",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitReturns": true,
|
||||
"strict": true
|
||||
"outDir": "./out"
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
|
|
Loading…
Reference in a new issue