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