diff --git a/packages/schematics/angular/web-worker/index.ts b/packages/schematics/angular/web-worker/index.ts index 717a3741bfe4..012566b1df0a 100644 --- a/packages/schematics/angular/web-worker/index.ts +++ b/packages/schematics/angular/web-worker/index.ts @@ -62,9 +62,11 @@ function addSnippet(options: WebWorkerOptions): Rule { return; } + const fileRegExp = new RegExp(`^${options.name}.*\.ts`); const siblingModules = host.getDir(options.path).subfiles - // Find all files that start with the same name, are ts files, and aren't spec files. - .filter(f => f.startsWith(options.name) && f.endsWith('.ts') && !f.endsWith('spec.ts')) + // Find all files that start with the same name, are ts files, + // and aren't spec or module files. + .filter(f => fileRegExp.test(f) && !/(module|spec)\.ts$/.test(f)) // Sort alphabetically for consistency. .sort(); diff --git a/packages/schematics/angular/web-worker/index_spec.ts b/packages/schematics/angular/web-worker/index_spec.ts index bc68cba035d5..a8f6520189c1 100644 --- a/packages/schematics/angular/web-worker/index_spec.ts +++ b/packages/schematics/angular/web-worker/index_spec.ts @@ -11,7 +11,7 @@ import { Schema as WorkspaceOptions } from '../workspace/schema'; import { Schema as WebWorkerOptions } from './schema'; -describe('Service Worker Schematic', () => { +describe('Web Worker Schematic', () => { const schematicRunner = new SchematicTestRunner( '@schematics/angular', require.resolve('../collection.json'), @@ -35,7 +35,7 @@ describe('Service Worker Schematic', () => { name: 'bar', inlineStyle: false, inlineTemplate: false, - routing: false, + routing: true, skipTests: false, skipPackageJson: false, };