本文整理汇总了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);
}