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


TypeScript tool.isExplicitVersion函数代码示例

本文整理汇总了TypeScript中vsts-task-tool-lib/tool.isExplicitVersion函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isExplicitVersion函数的具体用法?TypeScript isExplicitVersion怎么用?TypeScript isExplicitVersion使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了isExplicitVersion函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

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

示例2: constructor

 constructor(packageType, version) {
     this.packageType = packageType;
     if (!toolLib.isExplicitVersion(version)) {
         throw tl.loc("ImplicitVersionNotSupported", version);
     }
     this.version = version;
     this.cachedToolName = this.packageType === 'runtime' ? 'dncr' : 'dncs';;
 }
开发者ID:grawcho,项目名称:vso-agent-tasks,代码行数:8,代码来源:dotnetcoreinstaller.ts

示例3: installVsTestPlatformToolFromNetworkShare

    // Installs the test platform from a network share path provided by the user. The path should point to a .nupkg file.
    public async installVsTestPlatformToolFromNetworkShare(netSharePath: string) {
        let vstestPlatformInstalledLocation;
        let packageSource;

        // Remove all double quotes from the path.
        netSharePath = netSharePath.replace(/["]+/g, '');

        tl.debug(`Attempting to fetch the vstest platform from the specified network share path ${netSharePath}.`);

        if (helpers.pathExistsAsFile(netSharePath)) {
            packageSource = path.dirname(netSharePath);
        } else {
            ci.addToConsolidatedCi('failureReason', constants.packageFileDoesNotExist);
            throw new Error(tl.loc('SpecifiedFileDoesNotExist', netSharePath));
        }

        const fileName = path.basename(netSharePath);
        const versionExtractionRegex = constants.versionExtractionRegex;
        const regexMatches = versionExtractionRegex.exec(fileName);

        if (!regexMatches || regexMatches.length !== 2) {
            ci.addToConsolidatedCi('failureReason', constants.unexpectedPackageFileName);
            throw new Error(tl.loc('UnexpectedFileName', fileName));
        }
        const testPlatformVersion = regexMatches[1];
        ci.addToConsolidatedCi('testPlatformVersion', testPlatformVersion);

        // If the version provided is not an explicit version (ie contains containing wildcards) then throw
        if (!toolLib.isExplicitVersion(testPlatformVersion)) {
            ci.publishEvent('InvalidVersionSpecified', { version: testPlatformVersion } );
            ci.addToConsolidatedCi('failureReason', constants.notExplicitVersion);
            throw new Error(tl.loc('ProvideExplicitVersion', testPlatformVersion));
        }

        console.log(tl.loc('ParsedVersion', testPlatformVersion));
        tl.debug(`Looking for version ${testPlatformVersion} in the tools cache.`);
        startTime = perf();

        // Check cache for the specified version
        vstestPlatformInstalledLocation = toolLib.findLocalTool(constants.toolFolderName, testPlatformVersion);

        ci.addToConsolidatedCi('cacheLookupTime', perf() - startTime);

        // If found in the cache then set the tool location and return
        if (!helpers.isNullEmptyOrUndefined(vstestPlatformInstalledLocation)) {
            ci.addToConsolidatedCi('firstCacheLookupSucceeded', 'true');
            helpers.setVsTestToolLocation(vstestPlatformInstalledLocation);
            return;
        }

        ci.addToConsolidatedCi('firstCacheLookupSucceeded', 'false');

        vstestPlatformInstalledLocation = await new NugetDownloadHelper()
            .attemptPackageDownload(packageSource, testPlatformVersion, null);

        // Set the vstest platform tool location for the vstest task to consume
        helpers.setVsTestToolLocation(vstestPlatformInstalledLocation);
    }
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:59,代码来源:networkshareinstaller.ts

示例4: isVersionInstalled

    public isVersionInstalled(version: string): boolean {
        if (!toolLib.isExplicitVersion(version)) {
            throw tl.loc("ExplicitVersionRequired", version);
        }

        var isInstalled: boolean = false;
        if (this.packageType == utils.Constants.sdk) {
            isInstalled = tl.exist(path.join(this.installationPath, utils.Constants.relativeSdkPath, version)) && tl.exist(path.join(this.installationPath, utils.Constants.relativeSdkPath, `${version}.complete`));
        }
        else {
            isInstalled = tl.exist(path.join(this.installationPath, utils.Constants.relativeRuntimePath, version)) && tl.exist(path.join(this.installationPath, utils.Constants.relativeRuntimePath, `${version}.complete`));
        }

        isInstalled ? console.log(tl.loc("VersionFoundInCache", version)) : console.log(tl.loc("VersionNotFoundInCache", version));
        return isInstalled;
    }
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:16,代码来源:versioninstaller.ts

示例5: getDotnetCore

async function getDotnetCore(packageType: string, version: string): Promise<void> {
    if (!toolLib.isExplicitVersion(version)) {
        throw taskLib.loc("ImplicitVersionNotSupported", version);
    }

    // check cache
    let toolPath: string;
    toolPath = getLocalTool(packageType, version);

    if (!toolPath) {
        // download, extract, cache
        console.log(taskLib.loc("InstallingAfresh"));
        toolPath = await acquireDotNetCore(packageType, version);
    } else {
        console.log(taskLib.loc("UsingCachedTool", toolPath));
    }

    // prepend the tools path. instructs the agent to prepend for future tasks
    toolLib.prependPath(toolPath);
}
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:20,代码来源:dotnetcoreinstaller.ts

示例6: installVsTestPlatformToolFromSpecifiedFeed

    // Installs the test platform from the feed specified. If platfornVersion is null then the versionSelectorInput is read and the version
    // is determined accordingly. Additionally provide the config file to help with authentication if the feed is a custom feed.
    public async installVsTestPlatformToolFromSpecifiedFeed(packageSource: string, testPlatformVersion: string, versionSelectorInput: string, nugetConfigFilePath: string) {
        let vstestPlatformInstalledLocation: string;
        let includePreRelease: boolean;

        ci.addToConsolidatedCi('versionSelectorInput', versionSelectorInput);
        tl.debug(`Using the package source ${packageSource} to get the ${constants.packageId} nuget package.`);

        if (!helpers.isNullEmptyOrUndefined(nugetConfigFilePath)) {
            tl.debug(`Using provided config file ${nugetConfigFilePath}.`);
        }

        if (versionSelectorInput.toLowerCase() === constants.latestStable) {
            console.log(tl.loc('LookingForLatestStableVersion'));
            testPlatformVersion = null;
            includePreRelease = false;

        } else if (versionSelectorInput.toLowerCase() === constants.latestPrerelease) {
            console.log(tl.loc('LookingForLatestPreReleaseVersion'));
            testPlatformVersion = null;
            includePreRelease = true;
        }

        if (versionSelectorInput.toLowerCase() !== constants.specificVersion) {

            try {
                ci.addToConsolidatedCi('latestVersionIdentified', 'false');
                testPlatformVersion = new NugetPackageVersionHelper()
                    .getLatestPackageVersionNumber(packageSource, includePreRelease, nugetConfigFilePath);

                if (helpers.isNullEmptyOrUndefined(testPlatformVersion)) {

                    tl.warning(tl.loc('RequiredVersionNotListed'));
                    tl.debug('Looking for latest stable available version in cache.');
                    ci.publishEvent('RequestedVersionNotListed', { action: 'getLatestAvailableInCache' } );
                    // Look for the latest stable version available in the cache
                    testPlatformVersion = 'x';

                } else {
                    ci.addToConsolidatedCi('latestVersionIdentified', 'true');
                    tl.debug(`Found the latest version to be ${testPlatformVersion}.`);
                    ci.publishEvent('RequestedVersionListed', { action: 'lookInCacheForListedVersion', version: testPlatformVersion } );
                }

            } catch (error) {
                // Failed to list available versions, look for the latest stable version available in the cache
                tl.error(`${tl.loc('FailedToListAvailablePackagesFromNuget')}\n${error}`);
                tl.debug('Looking for latest stable version available version in cache.');
                ci.publishEvent('RequestedVersionListFailed', { action: 'getLatestAvailableInCache', error: error } );
                testPlatformVersion = 'x';
            }
        }

        tl.debug(`Looking for version ${testPlatformVersion} in the tools cache.`);
        startTime = perf();

        // Check cache for the specified version
        vstestPlatformInstalledLocation = toolLib.findLocalTool(constants.toolFolderName, testPlatformVersion);

        ci.addToConsolidatedCi('cacheLookupTime', perf() - startTime);

        // If found in the cache then set the tool location and return
        if (!helpers.isNullEmptyOrUndefined(vstestPlatformInstalledLocation)) {
            ci.addToConsolidatedCi('firstCacheLookupSucceeded', 'true');
            helpers.setVsTestToolLocation(vstestPlatformInstalledLocation);
            return;
        }

        ci.addToConsolidatedCi('firstCacheLookupSucceeded', 'false');

        // If the testPlatformVersion is 'x' meaning listing failed and we were looking for a stable version in the cache
        // and the cache lookup failed, then fail the task
        if (!testPlatformVersion || testPlatformVersion === 'x') {
            tl.error(tl.loc('NoPackageFoundInCache'));
            ci.addToConsolidatedCi('failureReason', constants.listingFailed);
            throw new Error(tl.loc('FailedToAcquireTestPlatform'));
        }

        // If the version provided is not an explicit version (ie contains containing wildcards) then throw
        if (!toolLib.isExplicitVersion(testPlatformVersion)) {
            ci.publishEvent('InvalidVersionSpecified', { version: testPlatformVersion } );
            ci.addToConsolidatedCi('failureReason', constants.notExplicitVersion);
            throw new Error(tl.loc('ProvideExplicitVersion', testPlatformVersion));
        }

        vstestPlatformInstalledLocation = await new NugetDownloadHelper()
            .attemptPackageDownload(packageSource, testPlatformVersion, nugetConfigFilePath);

        // Set the vstest platform tool location for the vstest task to consume
        helpers.setVsTestToolLocation(vstestPlatformInstalledLocation);
    }
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:92,代码来源:nugetfeedinstaller.ts


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