Skip to content

Commit f9d8c7a

Browse files
cexbrayatclydin
authored andcommitted
fix(@angular/cli): allow RCs and betas for @angular/service-worker
It was not possible to use `5.1.0-rc.1` previously, because of how `semver.satisfies()` works (see https://github.com/npm/node-semver#prerelease-tags). This relaxes the check by using `semver.gte()`.
1 parent d5a5fe2 commit f9d8c7a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/@angular/cli/models/webpack-configs/production.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function getProdConfig(wco: WebpackConfigOptions) {
4747
const swVersion = JSON.parse(swPackageJson)['version'];
4848

4949
const isLegacySw = semver.satisfies(swVersion, OLD_SW_VERSION);
50-
const isModernSw = semver.satisfies(swVersion, NEW_SW_VERSION);
50+
const isModernSw = semver.gte(swVersion, NEW_SW_VERSION);
5151

5252
if (!isLegacySw && !isModernSw) {
5353
throw new Error(stripIndent`

packages/@angular/cli/utilities/service-worker/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as fs from 'fs';
55
import * as path from 'path';
66
import * as semver from 'semver';
77

8-
export const NEW_SW_VERSION = '>= 5.0.0-rc.0';
8+
export const NEW_SW_VERSION = '5.0.0-rc.0';
99

1010
class CliFilesystem implements Filesystem {
1111
constructor(private base: string) {}
@@ -58,7 +58,7 @@ export function usesServiceWorker(projectRoot: string): boolean {
5858
const swPackageJson = fs.readFileSync(`${swModule}/package.json`).toString();
5959
const swVersion = JSON.parse(swPackageJson)['version'];
6060

61-
return semver.satisfies(swVersion, NEW_SW_VERSION);
61+
return semver.gte(swVersion, NEW_SW_VERSION);
6262
}
6363

6464
export function augmentAppWithServiceWorker(projectRoot: string, appRoot: string,

0 commit comments

Comments
 (0)