本文整理汇总了TypeScript中vsts-task-tool-lib/tool.cleanVersion函数的典型用法代码示例。如果您正苦于以下问题:TypeScript cleanVersion函数的具体用法?TypeScript cleanVersion怎么用?TypeScript cleanVersion使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cleanVersion函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: sanitizeVersionString
export function sanitizeVersionString(inputVersion: string) : string{
var version = toolLib.cleanVersion(inputVersion);
if(!version) {
throw new Error(tl.loc("NotAValidSemverVersion"));
}
return "v"+version;
}
示例2: acquireNode
async function acquireNode(version: string): Promise<string> {
//
// Download - a tool installer intimately knows how to get the tool (and construct urls)
//
version = toolLib.cleanVersion(version);
let fileName: string = osPlat == 'win32'? 'node-v' + version + '-win-' + os.arch() :
'node-v' + version + '-' + osPlat + '-' + os.arch();
let urlFileName: string = osPlat == 'win32'? fileName + '.7z':
fileName + '.tar.gz';
let downloadUrl = 'https://nodejs.org/dist/v' + version + '/' + urlFileName;
let downloadPath: string;
try
{
downloadPath = await toolLib.downloadTool(downloadUrl);
}
catch (err)
{
if (err['httpStatusCode'] &&
err['httpStatusCode'] == '404')
{
return await acquireNodeFromFallbackLocation(version);
}
throw err;
}
//
// Extract
//
let extPath: string;
if (osPlat == 'win32') {
taskLib.assertAgent('2.115.0');
extPath = taskLib.getVariable('Agent.TempDirectory');
if (!extPath) {
throw new Error('Expected Agent.TempDirectory to be set');
}
extPath = path.join(extPath, 'n'); // use as short a path as possible due to nested node_modules folders
extPath = await toolLib.extract7z(downloadPath, extPath);
}
else {
extPath = await toolLib.extractTar(downloadPath);
}
//
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
//
let toolRoot = path.join(extPath, fileName);
return await toolLib.cacheDir(toolRoot, 'node', version);
}
示例3: acquireAndCacheVsTestPlatformNuget
// Downloads and caches the test platform package
private async acquireAndCacheVsTestPlatformNuget(packageSource: string, testPlatformVersion: string, nugetConfigFilePath: string): Promise<string> {
testPlatformVersion = toolLib.cleanVersion(testPlatformVersion);
const nugetTool = tl.tool(path.join(__dirname, 'nuget.exe'));
let downloadPath = helpers.getTempFolder();
// Ensure Agent.TempDirectory is set
if (!downloadPath) {
throw new Error(tl.loc('ExpectedTempToBeSet'));
}
// Call out a warning if the agent work folder path is longer than 50 characters as anything longer may cause the download to fail
// Note: This upper limit was calculated for a particular test platform package version and is subject to change
if (tl.getVariable(constants.agentWorkFolder) && tl.getVariable(constants.agentWorkFolder).length > 50) {
ci.addToConsolidatedCi('agentWorkDirectoryPathTooLong', 'true');
tl.warning(tl.loc('AgentWorkDirectoryPathTooLong'));
}
// Use as short a path as possible due to nested folders in the package that may potentially exceed the 255 char windows path limit
downloadPath = path.join(downloadPath, constants.toolFolderName);
nugetTool.arg(constants.install).arg(constants.packageId).arg(constants.version).arg(testPlatformVersion).arg(constants.source)
.arg(packageSource).arg(constants.outputDirectory).arg(downloadPath).arg(constants.noCache).arg(constants.directDownload)
.argIf(nugetConfigFilePath, constants.configFile).argIf(nugetConfigFilePath, nugetConfigFilePath).arg(constants.noninteractive);
tl.debug(`Downloading Test Platform version ${testPlatformVersion} from ${packageSource} to ${downloadPath}.`);
startTime = perf();
const resultCode = await nugetTool.exec();
ci.addToConsolidatedCi('downloadTime', perf() - startTime);
tl.debug(`Nuget.exe returned with result code ${resultCode}`);
if (resultCode !== 0) {
tl.error(tl.loc('NugetErrorCode', resultCode));
throw new Error(tl.loc('DownloadFailed', resultCode));
}
// Install into the local tool cache
const toolRoot = path.join(downloadPath, constants.packageId + '.' + testPlatformVersion);
tl.debug(`Caching the downloaded folder ${toolRoot}.`);
startTime = perf();
const vstestPlatformInstalledLocation = await toolLib.cacheDir(toolRoot, constants.toolFolderName, testPlatformVersion);
ci.addToConsolidatedCi('cacheTime', perf() - startTime);
return vstestPlatformInstalledLocation;
}