當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。