当前位置: 首页>>代码示例>>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;未经允许,请勿转载。