• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript task.which函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中vsts-task-lib/task.which函数的典型用法代码示例。如果您正苦于以下问题:TypeScript which函数的具体用法?TypeScript which怎么用?TypeScript which使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了which函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: 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;
    }
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:53,代码来源:versionfetcher.ts


示例2: getHelm

export async function getHelm(version?: string) {
    try {
        return Promise.resolve(tl.which("helm", true));
    } catch (ex) {
        return downloadHelm(version);
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:7,代码来源:helmutility.ts


示例3: getKubectl

export async function getKubectl(): Promise<string> {
    try {
        return Promise.resolve(tl.which("kubectl", true));
    } catch (ex) {
        return kubectlutility.downloadKubectl(await kubectlutility.getStableKubectlVersion());
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:7,代码来源:utilities.ts


示例4: constructor

 constructor(existingKubeConfigPath?: string) {
     this.kubectlPath = tl.which("kubectl", false);
     this.userDir = utils.getNewUserDirPath();
     if (existingKubeConfigPath) {
         this.kubeconfigFile = existingKubeConfigPath;
     }
 }
开发者ID:grawcho,项目名称:vso-agent-tasks,代码行数:7,代码来源:clusterconnection.ts


示例5: getPortableOctoCommandRunner

export function getPortableOctoCommandRunner(command: string) : Option<ToolRunner>{
    const octo = stringOption(tasks.which(`${ToolName}.dll`, false));
    const dotnet = tasks.which("dotnet", false);

    if (isNullOrWhitespace(dotnet)){
        tasks.warning("DotNet core 2.0 runtime was not found and this task will most likely fail. Target an agent which has the appropriate capability or add a DotNet core installer task to the start of you build definition to fix this problem.")
    }

    const tool = tasks.tool(tasks.which("dotnet", true));

    var result =  octo.map(x => tool
        .arg(`${x}`)
        .arg(command)
    );

    return result;
}
开发者ID:OctopusDeploy,项目名称:OctoTFS,代码行数:17,代码来源:tool.ts


示例6: 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);
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:12,代码来源:conda_internal.ts


示例7: installTypings

function installTypings() {
	const tool = tl.createToolRunner(tl.which("npm", true));
    tool.arg("install");
    tool.arg("-g");
    tool.arg("typings");
    
    return tool.exec()
        .then(() => { typings = tl.which("typings", true); });
}
开发者ID:touchifyapp,项目名称:vsts-typings,代码行数:9,代码来源:typingstask.ts


示例8: getOctoCommandRunner

export function getOctoCommandRunner(command: string) : Option<ToolRunner> {
    const isWindows = /windows/i.test(tasks.osType());
    if(isWindows){
        return stringOption(tasks.which(`${ToolName}`, false))
        .map(tasks.tool)
        .map(x => x.arg(command));
    }

    return getPortableOctoCommandRunner(command);
}
开发者ID:OctopusDeploy,项目名称:OctoTFS,代码行数:10,代码来源:tool.ts


示例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());
}
开发者ID:touchifyapp,项目名称:vsts-bower,代码行数:11,代码来源:bowertask.ts


示例10: tagsAt

export function tagsAt(commit: string): string[] {
    var git = tl.which("git", true);
    var args = ["tag", "--points-at", commit];
    var gitDir = tl.getVariable("Build.Repository.LocalPath");
    console.log("[command]" + git + " " + args.join(" "));
    var result = (cp.execFileSync(git, args, {
        encoding: "utf8",
        cwd: gitDir
    }) as string).trim();
    console.log(result);
    return result.length ? result.split("\n") : [];
}
开发者ID:DarqueWarrior,项目名称:vsts-tasks,代码行数:12,代码来源:gitutils.ts



注:本文中的vsts-task-lib/task.which函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript task.writeFile函数代码示例发布时间:2022-05-25
下一篇:
TypeScript task.warning函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap