當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ToolRunner.execSync方法代碼示例

本文整理匯總了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"));
    }
}
開發者ID:Microsoft,項目名稱:vsts-extension-build-release-tasks,代碼行數:30,代碼來源:TfxInstaller.ts

示例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 "";
}
開發者ID:Microsoft,項目名稱:vsts-extension-build-release-tasks,代碼行數:12,代碼來源:TfxInstaller.ts


注:本文中的azure-pipelines-task-lib/toolrunner.ToolRunner.execSync方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。