当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript task.which函数代码示例

本文整理汇总了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;未经允许,请勿转载。