本文整理匯總了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 "";
}