本文整理汇总了TypeScript中azure-pipelines-task-lib/toolrunner.ToolRunner.execSync方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ToolRunner.execSync方法的具体用法?TypeScript ToolRunner.execSync怎么用?TypeScript ToolRunner.execSync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类azure-pipelines-task-lib/toolrunner.ToolRunner
的用法示例。
在下文中一共展示了ToolRunner.execSync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: acquireTfx
async function acquireTfx(version: string): Promise<string> {
try{
version = toolLib.cleanVersion(version);
let extPath: string;
taskLib.assertAgent('2.115.0');
extPath = taskLib.getVariable('Agent.TempDirectory');
if (!extPath) {
throw new Error('Expected Agent.TempDirectory to be set');
}
extPath = path.join(extPath, 'tfx'); // use as short a path as possible due to nested node_modules folders
taskLib.mkdirP(path.join(extPath));
const npmRunner = new tr.ToolRunner("npm");
npmRunner.arg(["install", "tfx-cli@" + version, "--prefix", extPath]);
const result = npmRunner.execSync({ failOnStdErr: false, silent: true, ignoreReturnCode: false} as tr.IExecOptions);
if (result.code === 0)
{
if (os.platform() === "win32")
{
fs.unlinkSync(path.join(extPath, "/tfx"));
}
return await toolLib.cacheDir(extPath, 'tfx', version);
}
}
catch {
return Promise.reject(new Error("Failed to install tfx"));
}
}
示例2: queryLatestMatch
function queryLatestMatch(versionSpec: string): string {
const npmRunner = new tr.ToolRunner("npm");
npmRunner.arg(["show", "tfx-cli", "versions", "--json"]);
const result = npmRunner.execSync({ failOnStdErr: false, silent: true, ignoreReturnCode: false} as tr.IExecOptions);
if (result.code === 0)
{
let versions: string[] = JSON.parse(result.stdout.trim());
let version: string = toolLib.evaluateVersions(versions, versionSpec);
return version;
}
return "";
}