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

TypeScript semver.lte函数代码示例

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

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



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

示例1: return

  return (tree: Tree, context: SchematicContext) => {
    const schematicsToRun: { name: string; version: string; }[] = [];

    // Create the collection for the package.
    const collection = context.engine.createCollection(options.collection);
    for (const name of collection.listSchematicNames()) {
      const schematic = collection.createSchematic(name, true);

      const description: JsonObject = schematic.description as JsonObject;

      if (typeof description['version'] == 'string') {
        let version = description['version'] as string;
        if (!version.match(/^\d{1,30}\.\d{1,30}\.\d{1,30}$/)) {
          version += '.0';
        }
        if (!version.match(/^\d{1,30}\.\d{1,30}\.\d{1,30}$/)) {
          version += '.0';
        }
        if (!semver.valid(version)) {
          throw new SchematicsException(
            `Invalid migration version: ${JSON.stringify(description['version'])}`,
          );
        }

        if (semver.gt(version, options.from) && semver.lte(version, options.to)) {
          schematicsToRun.push({ name, version });
        }
      }
    }

    schematicsToRun.sort((a, b) => {
      const cmp = semver.compare(a.version, b.version);

      // Revert to comparing the names of the collection if the versions are equal.
      return cmp == 0 ? a.name.localeCompare(b.name) : cmp;
    });

    if (schematicsToRun.length > 0) {
      const rules = schematicsToRun.map(x => externalSchematic(options.collection, x.name, {}));

      return chain(rules);
    }

    return tree;
  };
开发者ID:fmalcher,项目名称:angular-cli,代码行数:45,代码来源:index.ts


示例2: _buildPackageInfo

function _buildPackageInfo(
  tree: Tree,
  packages: Map<string, VersionRange>,
  allDependencies: Map<string, VersionRange>,
  npmPackageJson: NpmRepositoryPackageJson,
  logger: logging.LoggerApi,
): PackageInfo {
  const name = npmPackageJson.name;
  const packageJsonRange = allDependencies.get(name);
  if (!packageJsonRange) {
    throw new SchematicsException(
      `Package ${JSON.stringify(name)} was not found in package.json.`,
    );
  }

  // Find out the currently installed version. Either from the package.json or the node_modules/
  // TODO: figure out a way to read package-lock.json and/or yarn.lock.
  let installedVersion: string | undefined;
  const packageContent = tree.read(`/node_modules/${name}/package.json`);
  if (packageContent) {
    const content = JSON.parse(packageContent.toString()) as JsonSchemaForNpmPackageJsonFiles;
    installedVersion = content.version;
  }
  if (!installedVersion) {
    // Find the version from NPM that fits the range to max.
    installedVersion = semver.maxSatisfying(
      Object.keys(npmPackageJson.versions),
      packageJsonRange,
    );
  }

  const installedPackageJson = npmPackageJson.versions[installedVersion] || packageContent;
  if (!installedPackageJson) {
    throw new SchematicsException(
      `An unexpected error happened; package ${name} has no version ${installedVersion}.`,
    );
  }

  let targetVersion: VersionRange | undefined = packages.get(name);
  if (targetVersion) {
    if (npmPackageJson['dist-tags'][targetVersion]) {
      targetVersion = npmPackageJson['dist-tags'][targetVersion] as VersionRange;
    } else if (targetVersion == 'next') {
      targetVersion = npmPackageJson['dist-tags']['latest'] as VersionRange;
    } else {
      targetVersion = semver.maxSatisfying(
        Object.keys(npmPackageJson.versions),
        targetVersion,
      ) as VersionRange;
    }
  }

  if (targetVersion && semver.lte(targetVersion, installedVersion)) {
    logger.debug(`Package ${name} already satisfied by package.json (${packageJsonRange}).`);
    targetVersion = undefined;
  }

  const target: PackageVersionInfo | undefined = targetVersion
    ? {
      version: targetVersion,
      packageJson: npmPackageJson.versions[targetVersion],
      updateMetadata: _getUpdateMetadata(npmPackageJson.versions[targetVersion], logger),
    }
    : undefined;

  // Check if there's an installed version.
  return {
    name,
    npmPackageJson,
    installed: {
      version: installedVersion as VersionRange,
      packageJson: installedPackageJson,
      updateMetadata: _getUpdateMetadata(installedPackageJson, logger),
    },
    target,
    packageJsonRange,
  };
}
开发者ID:iwe7,项目名称:devkit,代码行数:78,代码来源:index.ts


示例3:

strn = semver.inc(str, "minor", loose);
strn = semver.inc(str, "preminor", loose);
strn = semver.inc(str, "patch", loose);
strn = semver.inc(str, "prepatch", loose);
strn = semver.inc(str, "prerelease", loose);
strn = semver.inc(str, "prerelease", loose, "alpha");
num = semver.major(str, loose);
num = semver.minor(str, loose);
num = semver.patch(str, loose);
strArr = semver.prerelease(str, loose);

// Comparison
bool = semver.gt(v1, v2, loose);
bool = semver.gte(v1, v2, loose);
bool = semver.lt(v1, v2, loose);
bool = semver.lte(v1, v2, loose);
bool = semver.eq(v1, v2, loose);
bool = semver.neq(v1, v2, loose);
bool = semver.cmp(v1, op, v2, loose);
comparatorResult = semver.compare(v1, v2, loose);
comparatorResult = semver.rcompare(v1, v2, loose);
comparatorResult = semver.compareIdentifiers(str, str);
comparatorResult = semver.rcompareIdentifiers(str, str);
versionsArr = semver.sort(['', new semver.SemVer('')]);
versionsArr = semver.rsort(['', new semver.SemVer('')]);
diff = semver.diff(v1, v2, loose);

// Ranges
str = semver.validRange(str, loose);
bool = semver.satisfies(version, str, loose);
str = semver.maxSatisfying(versions, str, loose);
开发者ID:PriceSpider-NeuIntel,项目名称:DefinitelyTyped,代码行数:31,代码来源:semver-tests.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript semver.ltr函数代码示例发布时间:2022-05-25
下一篇:
TypeScript semver.lt函数代码示例发布时间: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