Skip to content

Commit ddfbbe6

Browse files
Alanmgechev
authored andcommitted
refactor: update file filtering logic for webworker snippet Insertion
1 parent 379bdd9 commit ddfbbe6

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

packages/schematics/angular/web-worker/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ function addSnippet(options: WebWorkerOptions): Rule {
6262
return;
6363
}
6464

65+
const fileRegExp = new RegExp(`^${options.name}.*\.ts`);
6566
const siblingModules = host.getDir(options.path).subfiles
66-
// Find all files that start with the same name, are ts files, and aren't spec files.
67-
.filter(f => f.startsWith(options.name) && f.endsWith('.ts') && !f.endsWith('spec.ts'))
67+
// Find all files that start with the same name, are ts files,
68+
// and aren't spec or module files.
69+
.filter(f => fileRegExp.test(f) && !/(module|spec)\.ts$/.test(f))
6870
// Sort alphabetically for consistency.
6971
.sort();
7072

packages/schematics/angular/web-worker/index_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Schema as WorkspaceOptions } from '../workspace/schema';
1111
import { Schema as WebWorkerOptions } from './schema';
1212

1313

14-
describe('Service Worker Schematic', () => {
14+
describe('Web Worker Schematic', () => {
1515
const schematicRunner = new SchematicTestRunner(
1616
'@schematics/angular',
1717
require.resolve('../collection.json'),
@@ -35,7 +35,7 @@ describe('Service Worker Schematic', () => {
3535
name: 'bar',
3636
inlineStyle: false,
3737
inlineTemplate: false,
38-
routing: false,
38+
routing: true,
3939
skipTests: false,
4040
skipPackageJson: false,
4141
};

0 commit comments

Comments
 (0)