本文整理汇总了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;
}
示例2: getHelm
export async function getHelm(version?: string) {
try {
return Promise.resolve(tl.which("helm", true));
} catch (ex) {
return downloadHelm(version);
}
}
示例3: getKubectl
export async function getKubectl(): Promise<string> {
try {
return Promise.resolve(tl.which("kubectl", true));
} catch (ex) {
return kubectlutility.downloadKubectl(await kubectlutility.getStableKubectlVersion());
}
}
示例4: constructor
constructor(existingKubeConfigPath?: string) {
this.kubectlPath = tl.which("kubectl", false);
this.userDir = utils.getNewUserDirPath();
if (existingKubeConfigPath) {
this.kubeconfigFile = existingKubeConfigPath;
}
}
示例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;
}
示例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);
}
}
示例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); });
}
示例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);
}
示例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());
}
示例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") : [];
}