本文整理匯總了TypeScript中vscode.tasks.executeTask方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript tasks.executeTask方法的具體用法?TypeScript tasks.executeTask怎麽用?TypeScript tasks.executeTask使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vscode.tasks
的用法示例。
在下文中一共展示了tasks.executeTask方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: runTest
function runTest(sourceUri: string, className: string, methodName: string): Thenable<TaskExecution> {
let file = Uri.parse(sourceUri).fsPath;
file = Path.relative(workspace.rootPath, file);
let kind: JavaTestTask = {
type: 'java.task.test',
className: className,
methodName: methodName,
}
var shell;
let config = workspace.getConfiguration('java')
// Run method or class
if (methodName != null) {
let command = config.get('testMethod') as string[]
if (command.length == 0) {
window.showErrorMessage('Set "java.testMethod" in .vscode/settings.json')
shell = new ShellExecution('echo', ['Set "java.testMethod" in .vscode/settings.json, for example ["mvn", "test", "-Dtest=${class}#${method}"]'])
} else {
shell = templateCommand(command, file, className, methodName)
}
} else {
let command = config.get('testClass') as string[]
if (command.length == 0) {
window.showErrorMessage('Set "java.testClass" in .vscode/settings.json')
shell = new ShellExecution('echo', ['Set "java.testClass" in .vscode/settings.json, for example ["mvn", "test", "-Dtest=${class}"]'])
} else {
shell = templateCommand(command, file, className, methodName)
}
}
let workspaceFolder = workspace.getWorkspaceFolder(Uri.parse(sourceUri))
let task = new Task(kind, workspaceFolder, 'Java Test', 'Java Language Server', shell)
return tasks.executeTask(task)
}
示例2: runScript
export function runScript(script: string, document: TextDocument) {
let uri = document.uri;
let folder = workspace.getWorkspaceFolder(uri);
if (folder) {
let task = createTask(script, `run ${script}`, folder, uri);
tasks.executeTask(task);
}
}
示例3: runScriptFromHover
public runScriptFromHover(args: any) {
let script = args.script;
let documentUri = args.documentUri;
let folder = workspace.getWorkspaceFolder(documentUri);
if (folder) {
let task = createTask(script, `run ${script}`, folder, documentUri);
tasks.executeTask(task);
}
}
示例4: runCommand
export function runCommand(folder: WorkspaceFolder, cmd: Cmd): Thenable<TaskExecution> {
const config: TaskConfigItem = {
definition: {
label: 'run Cargo command',
type: 'cargo',
command: cmd.binary,
args: cmd.args,
env: cmd.env,
},
problemMatcher: ['$rustc'],
group: TaskGroup.Build,
presentationOptions: {
reveal: TaskRevealKind.Always,
panel: TaskPanelKind.Dedicated,
},
};
const task = createTask(config, folder);
return tasks.executeTask(task);
}