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


TypeScript tool.cleanVersion函数代码示例

本文整理汇总了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;
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:8,代码来源:utils.ts

示例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);
}
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:53,代码来源:nodetool.ts

示例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;
    }
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:46,代码来源:nugetdownloadhelper.ts


注:本文中的vsts-task-tool-lib/tool.cleanVersion函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。