Example #1
0
function registerTaskProvider(context: vscode.ExtensionContext): vscode.Disposable | undefined {
	if (vscode.workspace.workspaceFolders) {
		let cachedTasks: vscode.Task[] | undefined = undefined;

		let flushCache = () => cachedTasks = undefined;
		let watcher = vscode.workspace.createFileSystemWatcher('**/package.json');
		watcher.onDidChange((_e) => flushCache());
		watcher.onDidDelete((_e) => flushCache());
		watcher.onDidCreate((_e) => flushCache());
		context.subscriptions.push(watcher);

		let provider: vscode.TaskProvider = {
			provideTasks: async () => {
				if (!cachedTasks) {
					cachedTasks = await provideNpmScripts();
				}
				return cachedTasks;
			},
			resolveTask(_task: vscode.Task): vscode.Task | undefined {
				return undefined;
			}
		};
		return vscode.workspace.registerTaskProvider('npm', provider);
	}
	return undefined;
}
Example #2
0
function registerTaskProvider(context: vscode.ExtensionContext): vscode.Disposable | undefined {

	function invalidateScriptCaches() {
		invalidateHoverScriptsCache();
		invalidateTasksCache();
		if (treeDataProvider) {
			treeDataProvider.refresh();
		}
	}

	if (vscode.workspace.workspaceFolders) {
		let watcher = vscode.workspace.createFileSystemWatcher('**/package.json');
		watcher.onDidChange((_e) => invalidateScriptCaches());
		watcher.onDidDelete((_e) => invalidateScriptCaches());
		watcher.onDidCreate((_e) => invalidateScriptCaches());
		context.subscriptions.push(watcher);

		let workspaceWatcher = vscode.workspace.onDidChangeWorkspaceFolders((_e) => invalidateScriptCaches());
		context.subscriptions.push(workspaceWatcher);

		let provider: vscode.TaskProvider = new NpmTaskProvider();
		let disposable = vscode.workspace.registerTaskProvider('npm', provider);
		context.subscriptions.push(disposable);
		return disposable;
	}
	return undefined;
}
Example #3
0
export async function registerTaskProvider(ctx: vscode.ExtensionContext) {
	let rakePromise: Thenable<vscode.Task[]> | undefined = undefined;
	let files = await vscode.workspace.findFiles("**/[rR]akefile{,.rb}");
	for (let i = 0; i < files.length; i++) {
		rakeFiles.add(files[i]);
	}

	let fileWatcher = vscode.workspace.createFileSystemWatcher("**/[rR]akefile{,.rb}");
	fileWatcher.onDidChange(() => rakePromise = undefined);
	fileWatcher.onDidCreate((uri) => {
		rakeFiles.add(uri);
		rakePromise = undefined
	});
	fileWatcher.onDidDelete((uri) => {
		rakeFiles.delete(uri);
		rakePromise = undefined
	});

	let taskProvider = vscode.workspace.registerTaskProvider('rake', {
		provideTasks: () => {
			if (!rakePromise) {
				rakePromise = getRakeTasks();
			}
			return rakePromise;
		},
		resolveTask(_task: vscode.Task): vscode.Task | undefined {
			return undefined;
		}
	});
}
Example #4
0
export function activate(context: vscode.ExtensionContext, settings: settings.ISettings) {
    g_context = context;
    g_settings = settings;

    taskProvider = vscode.workspace.registerTaskProvider('julia', {
        provideTasks: () => {
            return provideJuliaTasks();
        },
        resolveTask(_task: vscode.Task): vscode.Task | undefined {
            return undefined;
        }
    });
}
Example #5
0
export function activate(_context: vscode.ExtensionContext): void {
	if (!vscode.workspace.workspaceFolders) {
		return;
	}

	taskProvider = vscode.workspace.registerTaskProvider('npm', {
		provideTasks: () => {
			return provideNpmScripts();
		},
		resolveTask(_task: vscode.Task): vscode.Task | undefined {
			return undefined;
		}
	});
}
Example #6
0
	function onConfigurationChanged() {
		let autoDetect = vscode.workspace.getConfiguration('npm').get<AutoDetect>('autoDetect');
		if (taskProvider && autoDetect === 'off') {
			taskProvider.dispose();
			taskProvider = undefined;
		} else if (!taskProvider && autoDetect === 'on') {
			taskProvider = vscode.workspace.registerTaskProvider('npm', {
				provideTasks: () => {
					return provideNpmScripts();
				},
				resolveTask(_task: vscode.Task): vscode.Task | undefined {
					return undefined;
				}
			});
		}
	}
Example #7
0
 function onConfigurationChanged() {
     let autoDetect = vscode.workspace.getConfiguration('cake').get('taskRunner.autoDetect');
     if (taskProvider  && !autoDetect) {
         taskProvider.dispose();
         taskProvider = undefined;
     } else if (!taskProvider && autoDetect) {
         taskProvider = vscode.workspace.registerTaskProvider('cake', {
             provideTasks: async () => {
                 return await getCakeScriptsAsTasks();
             },
             resolveTask(_task: vscode.Task): vscode.Task | undefined {
                 return undefined;
             }
         });
     }
 }
Example #8
0
	function onConfigurationChanged() {
		let autoDetect = vscode.workspace.getConfiguration('grunt').get<AutoDetect>('autoDetect');
		if (taskProvider && autoDetect === 'off') {
			detectorPromise = undefined;
			taskProvider.dispose();
			taskProvider = undefined;
		} else if (!taskProvider && autoDetect === 'on') {
			taskProvider = vscode.workspace.registerTaskProvider({
				provideTasks: () => {
					if (!detectorPromise) {
						detectorPromise = getGruntTasks();
					}
					return detectorPromise;
				}
			});
		}
	}
Example #9
0
export function activate(context: vscode.ExtensionContext): void {
	if (!vscode.workspace.workspaceFolders) {
		return;
	}

	taskProvider = vscode.workspace.registerTaskProvider('npm', {
		provideTasks: () => {
			return provideNpmScripts();
		},
		resolveTask(_task: vscode.Task): vscode.Task | undefined {
			return undefined;
		}
	});
	configureHttpRequest();
	vscode.workspace.onDidChangeConfiguration(() => configureHttpRequest());

	context.subscriptions.push(addJSONProviders(httpRequest.xhr));
}
Example #10
0
	function onConfigurationChanged() {
		let autoDetect = vscode.workspace.getConfiguration('gulp').get<AutoDetect>('autoDetect');
		if (taskProvider && autoDetect === 'off') {
			gulpPromise = undefined;
			taskProvider.dispose();
			taskProvider = undefined;
		} else if (!taskProvider && autoDetect === 'on') {
			taskProvider = vscode.workspace.registerTaskProvider('gulp', {
				provideTasks: () => {
					if (!gulpPromise) {
						gulpPromise = getGulpTasks();
					}
					return gulpPromise;
				},
				resolveTask(_task: vscode.Task): vscode.Task | undefined {
					return undefined;
				}
			});
		}
	}
Example #11
0
export function activate(_context: vscode.ExtensionContext): void {
	let workspaceRoot = vscode.workspace.rootPath;
	if (!workspaceRoot) {
		return;
	}
	let gulpfile = path.join(workspaceRoot, 'gulpfile.js');
	let gulpPromise: Thenable<vscode.TaskSet> | undefined = undefined;
	let fileWatcher = vscode.workspace.createFileSystemWatcher(gulpfile);
	fileWatcher.onDidChange(() => gulpPromise = undefined);
	fileWatcher.onDidCreate(() => gulpPromise = undefined);
	fileWatcher.onDidDelete(() => gulpPromise = undefined);

	vscode.workspace.registerTaskProvider({
		provideTasks: () => {
			if (!gulpPromise) {
				gulpPromise = getGulpTasks();
			}
			return gulpPromise;
		}
	});
}