當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。