Skip to content

Commit 50ceb4d

Browse files
author
Alan
committed
refactor: update file filtering logic for webworker snippet Insertion
1 parent a155cab commit 50ceb4d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +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
6667
// Find all files that start with the same name, are ts files,
6768
// and aren't spec or module files.
68-
.filter(f => f.startsWith(options.name) && f.endsWith('.ts')
69-
&& !f.endsWith('spec.ts') && !f.endsWith('-.module.ts'))
69+
.filter(f => fileRegExp.test(f) && !/(module|spec)\.ts$/.test(f))
7070
// Sort alphabetically for consistency.
7171
.sort();
7272

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)