本文整理汇总了TypeScript中vsts-task-tool-lib/tool.prependPath函数的典型用法代码示例。如果您正苦于以下问题:TypeScript prependPath函数的具体用法?TypeScript prependPath怎么用?TypeScript prependPath使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了prependPath函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: prependCondaToPath
export function prependCondaToPath(condaRoot: string, platform: Platform): void {
if (platform === Platform.Windows) {
// Windows: `python` lives in `condaRoot` and `conda` lives in `condaRoot\Scripts`
tool.prependPath(condaRoot);
tool.prependPath(path.join(condaRoot, 'Scripts'));
} else {
// Linux and macOS: `python` and `conda` both live in the `bin` directory
tool.prependPath(path.join(condaRoot, 'bin'));
}
}
示例2:
return this.getKubectl().then((kubectlpath)=> {
this.kubectlPath = kubectlpath;
// prepend the tools path. instructs the agent to prepend for future tasks
if(!process.env['PATH'].toLowerCase().startsWith(path.dirname(this.kubectlPath.toLowerCase()))) {
toolLib.prependPath(path.dirname(this.kubectlPath));
}
});
示例3: useRubyVersion
export async function useRubyVersion(parameters: TaskParameters, platform: Platform): Promise<void> {
const toolName: string = 'Ruby';
const installDir: string | null = tool.findLocalTool(toolName, parameters.versionSpec);
if (!installDir) {
// Fail and list available versions
throw new Error([
task.loc('VersionNotFound', parameters.versionSpec),
task.loc('ListAvailableVersions'),
tool.findLocalToolVersions('Ruby')
].join(os.EOL));
}
const toolPath: string = path.join(installDir, 'bin');
if (platform !== Platform.Windows) {
// replace the default
const dest: string = '/usr/bin/ruby';
if (fs.existsSync(dest)) {
task.debug('removing ' + dest);
fs.unlinkSync(dest);
}
fs.symlinkSync(path.join(toolPath, 'ruby'), dest);
}
task.setVariable('rubyLocation', toolPath);
if (parameters.addToPath) {
tool.prependPath(toolPath);
}
}
示例4: useRubyVersion
export async function useRubyVersion(parameters: TaskParameters, platform: Platform): Promise<void> {
const toolName: string = 'Ruby';
const installDir: string | null = tool.findLocalTool(toolName, parameters.versionSpec);
if (!installDir) {
// Fail and list available versions
throw new Error([
task.loc('VersionNotFound', parameters.versionSpec),
task.loc('ListAvailableVersions', task.getVariable('Agent.ToolsDirectory')),
tool.findLocalToolVersions('Ruby'),
task.loc('ToolNotFoundMicrosoftHosted', 'Ruby', 'https://aka.ms/hosted-agent-software'),
task.loc('ToolNotFoundSelfHosted', 'Ruby', 'https://go.microsoft.com/fwlink/?linkid=2005989')
].join(os.EOL));
}
const toolPath: string = path.join(installDir, 'bin');
if (platform !== Platform.Windows) {
// Ruby / Gem heavily use the '#!/usr/bin/ruby' to find ruby, so this task needs to
// replace that version of ruby so all the correct version of ruby gets selected
// replace the default
const dest: string = '/usr/bin/ruby';
task.execSync('sudo', `ln -sf ${path.join(toolPath, 'ruby')} ${dest}`); // replace any existing
}
task.setVariable('rubyLocation', toolPath);
if (parameters.addToPath) {
tool.prependPath(toolPath);
}
}
示例5: run
async function run() {
let packageType = tl.getInput('packageType', true).toLowerCase();
let versionSpec = tl.getInput('version', true);
let installationPath = tl.getInput('installationPath', false);
if (!installationPath) {
installationPath = path.join(tl.getVariable('Agent.ToolsDirectory'), "dotnet");
}
let includePreviewVersions: boolean = tl.getBoolInput('includePreviewVersions', false) || false;
console.log(tl.loc("ToolToInstall", packageType, versionSpec));
var versionSpecParts = new VersionParts(versionSpec);
let versionFetcher = new DotNetCoreVersionFetcher();
let versionInfo: VersionInfo = await versionFetcher.getVersionInfo(versionSpecParts.versionSpec, packageType, includePreviewVersions);
if (!versionInfo) {
throw tl.loc("MatchingVersionNotFound", versionSpecParts.versionSpec);
}
let dotNetCoreInstaller = new VersionInstaller(packageType, installationPath);
if (!dotNetCoreInstaller.isVersionInstalled(versionInfo.getVersion())) {
await dotNetCoreInstaller.downloadAndInstall(versionInfo, versionFetcher.getDownloadUrl(versionInfo));
}
toolLib.prependPath(installationPath);
// By default disable Multi Level Lookup unless user wants it enabled.
let performMultiLevelLookup = tl.getBoolInput("performMultiLevelLookup", false);
tl.setVariable("DOTNET_MULTILEVEL_LOOKUP", !performMultiLevelLookup ? "0" : "1");
// Add dot net tools path to "PATH" environment variables, so that tools can be used directly.
addDotNetCoreToolPath();
// Set DOTNET_ROOT for dotnet core Apphost to find runtime since it is installed to a non well-known location.
tl.setVariable('DOTNET_ROOT', installationPath);
}
示例6: configureHelm
async function configureHelm() {
var version = await helminstaller.getHelmVersion();
var helmPath = await helminstaller.downloadHelm(version);
// prepend the tools path. instructs the agent to prepend for future tasks
if(!process.env['PATH'].startsWith(path.dirname(helmPath))) {
toolLib.prependPath(path.dirname(helmPath));
}
}
示例7: configureKubectl
async function configureKubectl() {
var version = await kubectlinstaller.getKuberctlVersion();
var kubectlPath = await kubectlinstaller.downloadKubectl(version);
// prepend the tools path. instructs the agent to prepend for future tasks
if(!process.env['PATH'].startsWith(path.dirname(kubectlPath))) {
toolLib.prependPath(path.dirname(kubectlPath));
}
}
示例8: install
public async install() {
// Check cache
let toolPath: string;
let osSuffixes = this.detectMachineOS();
let parts = osSuffixes[0].split("-");
this.arch = parts.length > 1 ? parts[1] : "x64";
toolPath = this.getLocalTool();
if (!toolPath) {
// download, extract, cache
console.log(tl.loc("InstallingAfresh"));
console.log(tl.loc("GettingDownloadUrl", this.packageType, this.version));
let downloadUrls = await DotNetCoreReleaseFetcher.getDownloadUrls(osSuffixes, this.version, this.packageType);
toolPath = await this.downloadAndInstall(downloadUrls);
} else {
console.log(tl.loc("UsingCachedTool", toolPath));
}
// Prepend the tools path. instructs the agent to prepend for future tasks
toolLib.prependPath(toolPath);
try {
let globalToolPath: string = "";
if (tl.osType().match(/^Win/)) {
globalToolPath = path.join(process.env.USERPROFILE, ".dotnet\\tools");
} else {
globalToolPath = path.join(process.env.HOME, ".dotnet/tools");
}
console.log(tl.loc("PrependGlobalToolPath"));
tl.mkdirP(globalToolPath);
toolLib.prependPath(globalToolPath);
} catch (error) {
//nop
}
// Set DOTNET_ROOT for dotnet core Apphost to find runtime since it is installed to a non well-known location.
tl.setVariable('DOTNET_ROOT', toolPath);
}
示例9: getNode
export async function getNode(versionSpec: string, checkLatest: boolean) {
if (toolLib.isExplicitVersion(versionSpec)) {
checkLatest = false; // check latest doesn't make sense when explicit version
}
// check cache
let toolPath: string;
if (!checkLatest) {
toolPath = toolLib.findLocalTool('node', versionSpec);
}
if (!toolPath) {
let version: string;
if (toolLib.isExplicitVersion(versionSpec)) {
// version to download
version = versionSpec;
}
else {
// query nodejs.org for a matching version
version = await queryLatestMatch(versionSpec);
if (!version) {
throw new Error(`Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`);
}
// check cache
toolPath = toolLib.findLocalTool('node', version)
}
if (!toolPath) {
// download, extract, cache
toolPath = await acquireNode(version);
}
}
//
// a tool installer initimately knows details about the layout of that tool
// for example, node binary is in the bin folder after the extract on Mac/Linux.
// layouts could change by version, by platform etc... but that's the tool installers job
//
if (osPlat != 'win32') {
toolPath = path.join(toolPath, 'bin');
}
//
// prepend the tools path. instructs the agent to prepend for future tasks
//
toolLib.prependPath(toolPath);
}
示例10: addDotNetCoreToolPath
function addDotNetCoreToolPath() {
try {
let globalToolPath: string = "";
if (tl.osType().match(/^Win/)) {
globalToolPath = path.join(process.env.USERPROFILE, Constants.relativeGlobalToolPath);
} else {
globalToolPath = path.join(process.env.HOME, Constants.relativeGlobalToolPath);
}
console.log(tl.loc("PrependGlobalToolPath"));
tl.mkdirP(globalToolPath);
toolLib.prependPath(globalToolPath);
} catch (error) {
//nop
console.log(tl.loc("ErrorWhileSettingDotNetToolPath", JSON.stringify(error)));
}
}