@probelabs/probe 0.6.0-rc173 → 0.6.0-rc174
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/build/agent/index.js +124 -75
- package/build/agent/probeTool.js +4 -13
- package/build/downloader.js +6 -2
- package/build/extractor.js +6 -2
- package/build/utils/file-lister.js +9 -2
- package/build/utils/symlink-utils.js +63 -0
- package/cjs/agent/ProbeAgent.cjs +121 -71
- package/cjs/index.cjs +124 -74
- package/package.json +2 -2
- package/src/agent/probeTool.js +4 -13
- package/src/downloader.js +6 -2
- package/src/extractor.js +6 -2
- package/src/utils/file-lister.js +9 -2
- package/src/utils/symlink-utils.js +63 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Symlink resolution utilities for the probe package
|
|
3
|
+
* @module utils/symlink-utils
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import { promises as fsPromises } from 'fs';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Get entry type following symlinks (async version)
|
|
11
|
+
*
|
|
12
|
+
* Uses fs.stat() which follows symlinks to get the actual target type.
|
|
13
|
+
* Falls back to dirent type if stat fails (e.g., broken symlink).
|
|
14
|
+
*
|
|
15
|
+
* @param {fs.Dirent} entry - Directory entry from readdir
|
|
16
|
+
* @param {string} fullPath - Full path to the entry
|
|
17
|
+
* @returns {Promise<{isFile: boolean, isDirectory: boolean, size: number}>}
|
|
18
|
+
*/
|
|
19
|
+
export async function getEntryType(entry, fullPath) {
|
|
20
|
+
try {
|
|
21
|
+
const stats = await fsPromises.stat(fullPath);
|
|
22
|
+
return {
|
|
23
|
+
isFile: stats.isFile(),
|
|
24
|
+
isDirectory: stats.isDirectory(),
|
|
25
|
+
size: stats.size
|
|
26
|
+
};
|
|
27
|
+
} catch {
|
|
28
|
+
// Fall back to dirent type if stat fails (e.g., broken symlink)
|
|
29
|
+
return {
|
|
30
|
+
isFile: entry.isFile(),
|
|
31
|
+
isDirectory: entry.isDirectory(),
|
|
32
|
+
size: 0
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Get entry type following symlinks (sync version)
|
|
39
|
+
*
|
|
40
|
+
* Uses fs.statSync() which follows symlinks to get the actual target type.
|
|
41
|
+
* Falls back to dirent type if stat fails (e.g., broken symlink).
|
|
42
|
+
*
|
|
43
|
+
* @param {fs.Dirent} entry - Directory entry from readdir
|
|
44
|
+
* @param {string} fullPath - Full path to the entry
|
|
45
|
+
* @returns {{isFile: boolean, isDirectory: boolean, size: number}}
|
|
46
|
+
*/
|
|
47
|
+
export function getEntryTypeSync(entry, fullPath) {
|
|
48
|
+
try {
|
|
49
|
+
const stats = fs.statSync(fullPath);
|
|
50
|
+
return {
|
|
51
|
+
isFile: stats.isFile(),
|
|
52
|
+
isDirectory: stats.isDirectory(),
|
|
53
|
+
size: stats.size
|
|
54
|
+
};
|
|
55
|
+
} catch {
|
|
56
|
+
// Fall back to dirent type if stat fails (e.g., broken symlink)
|
|
57
|
+
return {
|
|
58
|
+
isFile: entry.isFile(),
|
|
59
|
+
isDirectory: entry.isDirectory(),
|
|
60
|
+
size: 0
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|