本文整理汇总了TypeScript中vsts-task-lib/task.tool函数的典型用法代码示例。如果您正苦于以下问题:TypeScript tool函数的具体用法?TypeScript tool怎么用?TypeScript tool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tool函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: sudo
/**
* Run a tool with `sudo` on Linux and macOS
* Precondition: `toolName` executable is in PATH
*/
function sudo(toolName: string, platform: Platform): ToolRunner {
if (platform === Platform.Windows) {
return task.tool(toolName);
} else {
const toolPath = task.which(toolName);
return task.tool('sudo').line(toolPath);
}
}
示例2: detectMachineOS
private detectMachineOS(): string[] {
let osSuffix = [];
let scriptRunner: trm.ToolRunner;
try {
console.log(tl.loc("DetectingPlatform"));
if (tl.osType().match(/^Win/)) {
let escapedScript = path.join(this.getCurrentDir(), 'externals', 'get-os-platform.ps1').replace(/'/g, "''");
let command = `& '${escapedScript}'`
let powershellPath = tl.which('powershell', true);
scriptRunner = tl.tool(powershellPath)
.line('-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command')
.arg(command);
}
else {
let scriptPath = path.join(this.getCurrentDir(), 'externals', 'get-os-distro.sh');
this.setFileAttribute(scriptPath, "777");
scriptRunner = tl.tool(tl.which(scriptPath, true));
}
let result: trm.IExecSyncResult = scriptRunner.execSync();
if (result.code != 0) {
throw tl.loc("getMachinePlatformFailed", result.error ? result.error.message : result.stderr);
}
let output: string = result.stdout;
let index;
if ((index = output.indexOf("Primary:")) >= 0) {
let primary = output.substr(index + "Primary:".length).split(os.EOL)[0];
osSuffix.push(primary);
console.log(tl.loc("PrimaryPlatform", primary));
}
if ((index = output.indexOf("Legacy:")) >= 0) {
let legacy = output.substr(index + "Legacy:".length).split(os.EOL)[0];
osSuffix.push(legacy);
console.log(tl.loc("LegacyPlatform", legacy));
}
if (osSuffix.length == 0) {
throw tl.loc("CouldNotDetectPlatform");
}
}
catch (ex) {
throw tl.loc("FailedInDetectingMachineArch", JSON.stringify(ex));
}
return osSuffix;
}
示例3: createComposeCommand
public createComposeCommand(): tr.ToolRunner {
var command = tl.tool(this.dockerComposePath);
command.arg(["-f", this.dockerComposeFile]);
var basePath = path.dirname(this.dockerComposeFile);
this.additionalDockerComposeFiles.forEach(file => {
// If the path is relative, resolve it
if (file.indexOf("/") !== 0) {
file = path.join(basePath, file);
}
if (this.requireAdditionalDockerComposeFiles || tl.exist(file)) {
command.arg(["-f", file]);
}
});
if (this.finalComposeFile) {
command.arg(["-f", this.finalComposeFile]);
}
if (this.projectName) {
command.arg(["-p", this.projectName]);
}
return command;
}
示例4: executePythonTool
async function executePythonTool(commandToExecute){
var pythonTool = tl.tool(pythonToolPath);
pythonTool.on('stderr', function (data) {
error += (data || '').toString();
});
await pythonTool.line(commandToExecute).exec();
}
示例5: createCommand
public createCommand(): tr.ToolRunner {
var command = tl.tool(this.kubectlPath);
if(this.kubeconfigFile)
{
command.arg("--kubeconfig");
command.arg(this.kubeconfigFile);
}
return command;
}
示例6: updateConda
export async function updateConda(condaRoot: string, platform: Platform): Promise<void> {
try {
const conda = task.tool('conda');
conda.line('update --name base conda --yes');
await conda.exec();
} catch (e) {
// Best effort
}
}
示例7: getVSTestConsole15Path
function getVSTestConsole15Path(): string {
const vswhereTool = tl.tool(path.join(__dirname, 'vswhere.exe'));
vswhereTool.line('-version [15.0,16.0) -latest -products * -requires Microsoft.VisualStudio.PackageGroup.TestTools.Core -property installationPath');
let vsPath = vswhereTool.execSync().stdout;
tl.debug('Visual Studio 15.0 or higher installed path: ' + vsPath);
vsPath = utils.Helper.trimString(vsPath);
if (!utils.Helper.isNullOrWhitespace(vsPath)) {
return path.join(vsPath, 'Common7', 'IDE', 'CommonExtensions', 'Microsoft', 'TestWindow');
}
return null;
}
示例8: createCommand
public createCommand(): tr.ToolRunner {
var command = tl.tool(this.dockerPath);
if (this.hostUrl) {
command.arg(["-H", this.hostUrl]);
command.arg("--tls");
command.arg("--tlscacert='" + this.caPath + "'");
command.arg("--tlscert='" + this.certPath + "'");
command.arg("--tlskey='" + this.keyPath + "'");
}
return command;
}
示例9: getNPMPrefix
function getNPMPrefix(): string {
if (getNPMPrefix["value"]) {
return getNPMPrefix["value"];
}
const tool = tl.tool(tl.which("npm", true));
tool.arg("prefix");
tool.arg("-g");
return (getNPMPrefix["value"] = tool.execSync().stdout.trim());
}
示例10: installBower
function installBower(): Promise<void> {
const tool = tl.tool(tl.which("npm", true));
tool.arg("install");
tool.arg("-g");
tool.arg("bower");
return tool.exec().then(() => {
bower = findGlobalBower();
if (!bower) {
tl.setResult(tl.TaskResult.Failed, tl.loc("NpmGlobalNotInPath"));
throw new Error("NPM_GLOBAL_PREFIX_NOT_IN_PATH");
}
});
}