• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript tool.cleanVersion函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript tool.downloadTool函数代码示例发布时间:2022-05-25
下一篇:
TypeScript tool.cacheDir函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap