@nx/angular 21.4.0-beta.11 → 21.4.0-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"add-snippet.d.ts","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/web-worker/lib/add-snippet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"add-snippet.d.ts","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/web-worker/lib/add-snippet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAuChE"}
|
@@ -6,12 +6,13 @@ function addSnippet(tree, name, path) {
|
|
6
6
|
const fileRegExp = new RegExp(`^${name}.*\\.ts`);
|
7
7
|
const siblingModules = tree
|
8
8
|
.children(path)
|
9
|
-
.filter((f) => fileRegExp.test(f) &&
|
9
|
+
.filter((f) => fileRegExp.test(f) &&
|
10
|
+
!/\.(module|spec|config|routes)\.ts$/.test(f) &&
|
11
|
+
!f.endsWith('.worker.ts'))
|
10
12
|
.sort();
|
11
13
|
if (siblingModules.length === 0) {
|
12
14
|
return;
|
13
15
|
}
|
14
|
-
const siblingModulePath = (0, devkit_1.joinPathFragments)(path, siblingModules[0]);
|
15
16
|
const logMessage = 'console.log(`page got message ${data}`);';
|
16
17
|
const workerCreationSnippet = (0, devkit_1.stripIndents) `
|
17
18
|
if (typeof Worker !== 'undefined') {
|
@@ -26,7 +27,11 @@ function addSnippet(tree, name, path) {
|
|
26
27
|
// You should add a fallback so that your program still executes correctly.
|
27
28
|
}
|
28
29
|
`;
|
30
|
+
// Add snippet to the first alphabetically sorted sibling file
|
31
|
+
const siblingModulePath = (0, devkit_1.joinPathFragments)(path, siblingModules[0]);
|
29
32
|
const originalContent = tree.read(siblingModulePath, 'utf-8');
|
30
|
-
|
31
|
-
|
33
|
+
const newContent = originalContent.trim()
|
34
|
+
? `${originalContent}\n${workerCreationSnippet}`
|
35
|
+
: workerCreationSnippet;
|
36
|
+
tree.write(siblingModulePath, newContent);
|
32
37
|
}
|