當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript task.loc函數代碼示例

本文整理匯總了TypeScript中azure-pipelines-task-lib/task.loc函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript loc函數的具體用法?TypeScript loc怎麽用?TypeScript loc使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了loc函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: getAdvinst

async function getAdvinst(version: string, license: string): Promise<void> {

  if (!semvish.valid(version))
    throw Error(taskLib.loc("AI_InvalidVersionFormat", version));

  let cachedToolRoot: string;
  //Verify if this version of advinst was already installed.
  cachedToolRoot = _getLocalTool(semvish.clean(version));

  if (!cachedToolRoot) {
    console.log(taskLib.loc("AI_InstallNewTool"));
    //Extract advinst.msi and cache the content.
    cachedToolRoot = await acquireAdvinst(version);
  }
  else {
    console.log(taskLib.loc("AI_UseCachedTool", cachedToolRoot));
  }

  let msBuildTargetsPath: string = path.join(cachedToolRoot, advinstMSBuildTargetsSubPath);
  //Compute the actual AdvancedInstaller.com folder
  let advinstBinRoot: string = path.join(cachedToolRoot, advinstToolSubPath);
  //Debug traces
  taskLib.debug('cachedToolRoot = ' + cachedToolRoot);
  taskLib.debug('advinstBinRoot = ' + advinstBinRoot);
  taskLib.debug('msBuildTargetsPath = ' + msBuildTargetsPath);

  //Register advinst if a license key was provided
  await registerAdvinst(advinstBinRoot, license);
  //Add the advinst folder to PATH
  toolLib.prependPath(advinstBinRoot);

  //Set the environment variables that will be used by Advanced Installer tasks later on.
  taskLib.setVariable(advinstMSBuildTargetsVar, msBuildTargetsPath);
  taskLib.setVariable(advinstToolRootVar, cachedToolRoot);
}
開發者ID:Caphyon,項目名稱:advinst-vsts-task,代碼行數:35,代碼來源:AdvinstTool.ts

示例2: compareChannelVersion

export function compareChannelVersion(channelVersionA: string, channelVersionB: string): number {
    if (!channelVersionA || !channelVersionB) {
        throw "One channel version is missing"
    }

    let channelVersionAParts = channelVersionA.split(".");
    let channelVersionBParts = channelVersionB.split(".");
    if (channelVersionAParts.length != 2 || channelVersionBParts.length != 2) {
        throw tl.loc("ChannelVersionsNotComparable", channelVersionA, channelVersionB)
    }

    let channelAMajorVersion = Number.parseInt(channelVersionAParts[0]);
    let channelAMinorVersion = Number.parseInt(channelVersionAParts[1]);
    let channelBMajorVersion = Number.parseInt(channelVersionBParts[0]);
    let channelBMinorVersion = Number.parseInt(channelVersionBParts[1]);

    if (Number.isNaN(channelAMajorVersion) || Number.isNaN(channelAMinorVersion) || Number.isNaN(channelBMajorVersion) || Number.isNaN(channelBMinorVersion)) {
        throw tl.loc("ChannelVersionsNotComparable", channelVersionA, channelVersionB);
    }

    if (channelAMajorVersion != channelBMajorVersion) {
        return channelAMajorVersion > channelBMajorVersion ? 1 : -1;
    }
    else if (channelAMinorVersion != channelBMinorVersion) {
        return channelAMinorVersion > channelBMinorVersion ? 1 : -1;
    }

    return 0;
}
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:29,代碼來源:versionutilities.ts

示例3: isLatestInstalledVersion

    private isLatestInstalledVersion(version: string): boolean {
        var pathTobeChecked = this.packageType == utils.Constants.sdk ? path.join(this.installationPath, utils.Constants.relativeSdkPath) : path.join(this.installationPath, utils.Constants.relativeRuntimePath);
        if (!tl.exist(pathTobeChecked)) {
            throw tl.loc("PathNotFoundException", pathTobeChecked);
        }

        var allEnteries: string[] = tl.ls("", [pathTobeChecked]).map(name => path.join(pathTobeChecked, name));
        var folderPaths: string[] = allEnteries.filter(element => fs.lstatSync(element).isDirectory());
        var isLatest: boolean = folderPaths.findIndex(folderPath => {
            try {
                let versionFolderName = path.basename(folderPath);
                tl.debug(tl.loc("ComparingInstalledFolderVersions", version, versionFolderName));
                return utils.versionCompareFunction(versionFolderName, version) > 0;
            }
            catch (ex) {
                // no op, folder name might not be in version format
            }
        }) < 0;

        var filePaths: string[] = allEnteries.filter(element => !fs.lstatSync(element).isDirectory());
        isLatest = isLatest && filePaths.findIndex(filePath => {
            try {
                var versionCompleteFileName = this.getVersionCompleteFileName(path.basename(filePath));
                tl.debug(tl.loc("ComparingInstalledFileVersions", version, versionCompleteFileName));
                return utils.versionCompareFunction(versionCompleteFileName, version) > 0
            }
            catch (ex) {
                // no op, file name might not be in version format
            }
        }) < 0;

        isLatest ? tl.debug(tl.loc("VersionIsLocalLatest", version, this.installationPath)) : tl.debug(tl.loc("VersionIsNotLocalLatest", version, this.installationPath));
        return isLatest;
    }
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:34,代碼來源:versioninstaller.ts

示例4: _extractAdvinst

async function _extractAdvinst(sourceMsi: string): Promise<string> {
  console.log(taskLib.loc("AI_ExtractTool"));

  // Ensure the c:\windows\installer folder exists. MSIEXEC will fail on some clients (E.g. Hosted VS2017)
  // due to the lack of this folder.

  let windowsInstallerFolder = path.join(taskLib.getVariable('windir'), 'Installer');
  if (!taskLib.exist(windowsInstallerFolder)) {
    taskLib.debug(taskLib.loc("AI_CreateInstallerFolder"))
    taskLib.mkdirP(windowsInstallerFolder);
  }

  let advinstWorkFolder = path.join(_getAgentTemp(), 'AdvancedInstaller');
  let msiExtractionPath: string = path.join(advinstWorkFolder, 'resources');
  // Create the work folder, otherwise msiexec will fail because of the log path.
  if (!taskLib.exist(advinstWorkFolder))
    taskLib.mkdirP(advinstWorkFolder);
  let msiLogPath: string = path.join(advinstWorkFolder, 'advinst_install.log');

  let msiexecArguments: string[] = ['/a', sourceMsi, 'TARGETDIR=' + msiExtractionPath, '/qn', '/l*v', msiLogPath];

  let exitCode = taskLib.execSync('msiexec.exe', msiexecArguments).code;
  if (exitCode != 0) {
    taskLib.command('task.uploadfile', {}, msiLogPath);
    return null;
  }
  return msiExtractionPath;
}
開發者ID:Caphyon,項目名稱:advinst-vsts-task,代碼行數:28,代碼來源:AdvinstTool.ts

示例5: VersionInfo

                .then((body: string) => {
                    var channelReleases = JSON.parse(body).releases;

                    let versionInfoList: VersionInfo[] = [];
                    channelReleases.forEach((release) => {
                        if (release && release[packageType] && release[packageType].version) {
                            try {
                                let versionInfo: VersionInfo = new VersionInfo(release[packageType], packageType);
                                versionInfoList.push(versionInfo);
                            }
                            catch (err) {
                                tl.debug(tl.loc("VersionInformationNotComplete", release[packageType].version, err));
                            }
                        }
                    });

                    let matchedVersionInfo = utils.getMatchingVersionFromList(versionInfoList, versionSpec, includePreviewVersions);
                    if (!matchedVersionInfo) {
                        console.log(tl.loc("MatchingVersionNotFound", packageType, versionSpec));
                        return null;
                    }

                    console.log(tl.loc("MatchingVersionForUserInputVersion", matchedVersionInfo.getVersion(), channelInformation.channelVersion, versionSpec))
                    return matchedVersionInfo;
                })
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:25,代碼來源:versionfetcher.ts

示例6: run

async function run() {
    tl.setResourcePath(path.join( __dirname, 'task.json'));

    let taskInputs =  new OptimizelyTaskParameter();
    let taskOperation = new TaskOperation(taskInputs);

    let optimizelyClient = taskOperation.getOptimizelyClientInstance();

    let projectId: string = taskInputs.getProjectId();
    console.log(tl.loc("ProjectId", projectId));
    let project = await optimizelyClient.getProject(projectId);

    taskInputs.setProjectType(project.platform);

    let experimentId: string = taskInputs.getExperimentId();
    let experiment: IOptimizelyAlphaBetaTest = await optimizelyClient.getExperiment(projectId, experimentId);

    experiment = taskOperation.updateTrafficVariation(experiment);
    experiment.audience_conditions = await taskOperation.getAudienceCondition(projectId);

    let action: string = taskInputs.getAction();
    if (action.toLowerCase() === 'startabtest') {
        await taskOperation.startABTest(experiment);
    } else if (action.toLowerCase() === 'pauseabtest') {
        await taskOperation.pauseABTest(experiment);
    } else {
        throw tl.loc("InvalidAction", action);
    }
}
開發者ID:Microsoft,項目名稱:vsts-rm-extensions,代碼行數:29,代碼來源:Main.ts

示例7: getDownloadUrl

    public getDownloadUrl(versionInfo: VersionInfo): string {
        console.log(tl.loc("GettingDownloadUrl", versionInfo.getPackageType(), versionInfo.getVersion()));

        let osSuffixes = this.detectMachineOS();
        let downloadPackageInfoObject: VersionFilesData = null;
        osSuffixes.find((osSuffix) => {
            downloadPackageInfoObject = versionInfo.getFiles().find((downloadPackageInfo: VersionFilesData) => {
                if (downloadPackageInfo.rid && osSuffix && downloadPackageInfo.rid.toLowerCase() == osSuffix.toLowerCase()) {
                    if ((osSuffix.split("-")[0] == "win" && downloadPackageInfo.name.endsWith(".zip")) || (osSuffix.split("-")[0] != "win" && downloadPackageInfo.name.endsWith("tar.gz"))) {
                        return true;
                    }
                }

                return false;
            });

            return !!downloadPackageInfoObject;
        });

        if (!!downloadPackageInfoObject && downloadPackageInfoObject.url) {
            tl.debug("Got download URL for platform with rid: " + downloadPackageInfoObject.rid);
            return downloadPackageInfoObject.url;
        }

        throw tl.loc("DownloadUrlForMatchingOsNotFound", versionInfo.getPackageType(), versionInfo.getVersion(), osSuffixes.toString());
    }
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:26,代碼來源:versionfetcher.ts

示例8: startABTest

  public async startABTest(experiment: IOptimizelyAlphaBetaTest): Promise<void> {
      let environmentName: string = this.taskInputs.getEnvironmentName();
      let projectId: string = this.taskInputs.getProjectId();

      if(this.taskInputs.isWebProject()) {
          experiment.status = OptimizelyExperimentStatus.Running;
      } else {
          let environment: IOptimizelyEnvironment = await this.optimizelyClient.getEnvironment(projectId, environmentName);
          if (environment == null) {
              throw tl.loc("EnvironmentNotFound", environmentName);
          }

          Object.keys(experiment.environments).forEach((value) => {
              if (value.toLowerCase() == environmentName.toLowerCase()) {
                  experiment.environments[value].status = OptimizelyExperimentStatus.Running;
              }
          });
      }

      let experimentName = experiment.name;
      await this.optimizelyClient.updateExperiment(experiment.id, experiment);

      let counter: number = 6;
      while (counter > 0) {
          console.log(tl.loc("WaitingForExperimentToStart", experimentName));
          await this.sleep(10000);
          counter--;
      }

      console.log(tl.loc("ABTestStartedSuccessfully", experimentName));
      console.log(tl.loc("VisitOptimizelyPage") + ` https://app.optimizely.com/v2/projects/${projectId}/experiments`);
  }
開發者ID:Microsoft,項目名稱:vsts-rm-extensions,代碼行數:32,代碼來源:TaskOperation.ts

示例9: getVSTestConsolePath

export function getVSTestConsolePath(versionLowerLimit : string, versionUpperLimit : string): string {
    let vswhereTool = tl.tool(path.join(__dirname, 'vswhere.exe'));

    console.log(tl.loc('LookingForVsInstalltion'));
    vswhereTool.line(`-version [${versionLowerLimit},${versionUpperLimit}) -latest -products * -requires Microsoft.VisualStudio.PackageGroup.TestTools.Core -property installationPath`);
    let vsPath = vswhereTool.execSync({ silent: true } as tr.IExecSyncOptions).stdout;
    vsPath = utils.Helper.trimString(vsPath);
    if (!utils.Helper.isNullOrWhitespace(vsPath)) {
        tl.debug('Visual Studio 15.0 or higher installed path: ' + vsPath);
        return vsPath;
    }

    // look for build tool installation if full VS not present
    console.log(tl.loc('LookingForBuildToolsInstalltion'));
    vswhereTool = tl.tool(path.join(__dirname, 'vswhere.exe'));
    vswhereTool.line(`-version [${versionLowerLimit},${versionUpperLimit}) -latest -products * -requires Microsoft.VisualStudio.Component.TestTools.BuildTools -property installationPath`);
    vsPath = vswhereTool.execSync({ silent: true } as tr.IExecSyncOptions).stdout;
    vsPath = utils.Helper.trimString(vsPath);
    if (!utils.Helper.isNullOrWhitespace(vsPath)) {
        tl.debug('Build tools installed path: ' + vsPath);
        return vsPath;
    }

    return null;
}
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:25,代碼來源:versionfinder.ts

示例10: updateTrafficVariation

  public updateTrafficVariation(experiment: IOptimizelyAlphaBetaTest): IOptimizelyAlphaBetaTest {
      let totalTrafficParameter : string = this.taskInputs.getTotalTraffic();
      let totalTraffic: number = Number.parseInt(totalTrafficParameter);

      if (Number.isNaN(totalTraffic)) {
          throw tl.loc("TrafficValueNotValid", totalTrafficParameter);
      }

      if (totalTraffic > 100) {
          throw tl.loc("TrafficValueCantExceed", totalTraffic);
      }

      let holdBack: number = 10000 - (totalTraffic * 100);
      experiment.holdback = holdBack;
      let trafficByVariationKeyInput = this.taskInputs.getTrafficByVariation();
      let trafficVariations = this.parseTrafficByVariation(trafficByVariationKeyInput);

      for (let i: number = 0; i < experiment.variations.length; i++) {
          let variationKey: string = (this.taskInputs.isWebProject()) ? experiment.variations[i].name : experiment.variations[i].key;
          variationKey = variationKey.toLowerCase();
          if (!trafficVariations.has(variationKey)) {
              throw tl.loc("TrafficVariationKeyNotDefined", variationKey);
          }
          experiment.variations[i].weight = trafficVariations.get(variationKey);
      }

      return experiment;
  }
開發者ID:Microsoft,項目名稱:vsts-rm-extensions,代碼行數:28,代碼來源:TaskOperation.ts


注:本文中的azure-pipelines-task-lib/task.loc函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。