How to use the semver-intersect.parseRange function in semver-intersect

To help you get started, we’ve selected a few semver-intersect examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github angular / angular-cli / packages / schematics / package_update / utility / npm.ts View on Github external
mergeMap(({version, depName, depVersion, npmPackageJson}) => {
      const updateVersion = _getVersionFromNpmPackage(npmPackageJson, version, loose);
      const npmPackageVersions = Object.keys(npmPackageJson['versions'] as JsonObject);
      const match = semver.maxSatisfying(npmPackageVersions, updateVersion);
      if (!match) {
        return EMPTY;
      }
      if (semver.lt(
        semverIntersect.parseRange(updateVersion).version,
        semverIntersect.parseRange(depVersion).version)
      ) {
        throw new SchematicsException(`Cannot downgrade package ${
          JSON.stringify(depName)} from version "${depVersion}" to "${updateVersion}".`,
        );
      }

      const innerNpmPackageJson = (npmPackageJson['versions'] as JsonObject)[match] as JsonObject;
      const dependencies: { [name: string]: string } = {};

      const deps = innerNpmPackageJson['peerDependencies'] as JsonObject;
      if (deps) {
        for (const depName of Object.keys(deps)) {
          dependencies[depName] = deps[depName] as string;
        }
      }
github angular / angular-cli / packages / schematics / package_update / utility / npm.ts View on Github external
mergeMap(({version, depName, depVersion, npmPackageJson}) => {
      const updateVersion = _getVersionFromNpmPackage(npmPackageJson, version, loose);
      const npmPackageVersions = Object.keys(npmPackageJson['versions'] as JsonObject);
      const match = semver.maxSatisfying(npmPackageVersions, updateVersion);
      if (!match) {
        return EMPTY;
      }
      if (semver.lt(
        semverIntersect.parseRange(updateVersion).version,
        semverIntersect.parseRange(depVersion).version)
      ) {
        throw new SchematicsException(`Cannot downgrade package ${
          JSON.stringify(depName)} from version "${depVersion}" to "${updateVersion}".`,
        );
      }

      const innerNpmPackageJson = (npmPackageJson['versions'] as JsonObject)[match] as JsonObject;
      const dependencies: { [name: string]: string } = {};

      const deps = innerNpmPackageJson['peerDependencies'] as JsonObject;
      if (deps) {
        for (const depName of Object.keys(deps)) {
          dependencies[depName] = deps[depName] as string;
        }
      }

semver-intersect

Get the intersection of multiple semver ranges

MIT
Latest version published 12 months ago

Package Health Score

66 / 100
Full package analysis