@@ -82,19 +82,44 @@ Probe filesystem and path values:
8282``` ts
8383import {
8484 checkProcessDiskAccess ,
85+ checkProcessDiskUsage ,
8586 formatPath ,
87+ getProcessDiskUsage ,
8688 pathExists ,
8789} from " @unimolecule/utils/node" ;
8890
8991async function main() {
9092 await checkProcessDiskAccess (process .cwd ());
93+ const disk = await getProcessDiskUsage ({ path: process .cwd () });
94+ const diskCheck = await checkProcessDiskUsage ({
95+ maxUsedPercent: 0.9 ,
96+ minAvailableBytes: 1024 * 1024 * 1024 ,
97+ });
9198 await pathExists (" package.json" );
9299 formatPath (String .raw ` C:\U sers\i 7eo\a pp ` );
100+ console .log ({ disk , diskCheck });
93101}
94102
95103main ().catch (console .error );
96104```
97105
106+ Check process memory usage:
107+
108+ ``` ts
109+ import {
110+ checkProcessMemoryUsage ,
111+ getProcessMemoryUsage ,
112+ } from " @unimolecule/utils/node" ;
113+
114+ const memory = getProcessMemoryUsage ();
115+ const memoryCheck = checkProcessMemoryUsage ({
116+ maxHeapUsedBytes: 150 * 1024 * 1024 ,
117+ maxRssBytes: 512 * 1024 * 1024 ,
118+ });
119+
120+ console .log ({ memory , memoryCheck });
121+ ```
122+
98123Read local host addresses:
99124
100125``` ts
@@ -118,27 +143,31 @@ export default {
118143
119144## API
120145
121- | Export | Description |
122- | ---------------------------------------------- | ----------------------------------------------------------------------------------------- |
123- | ` appExists(app, options?) ` | Async PATH probe for an executable app. |
124- | ` appExistsSync(app, options?) ` | Sync PATH probe for an executable app. |
125- | ` checkProcessDiskAccess(path?) ` | Verifies read/write access for a path, defaulting to ` process.cwd() ` . |
126- | ` executeCommand(command, args?, options?) ` | Runs a command and resolves exit details when it succeeds. |
127- | ` executeCommandSync(command, args?, options?) ` | Sync command runner with the same success/error behavior. |
128- | ` formatPath(path) ` | Converts backslash separators to ` / ` while leaving Unix paths unchanged. |
129- | ` createProcessGracefulExit(logger?) ` | Creates isolated process signal registration and shutdown helpers. |
130- | ` exitSignals ` | Supported graceful shutdown signals: ` SIGINT ` , ` SIGQUIT ` , ` SIGTERM ` . |
131- | ` getLocalhostAddress() ` | Returns non-internal IPv4 addresses plus ` [::] ` , with duplicates removed. |
132- | ` getPackages(cwd?) ` | Async export from ` @manypkg/get-packages ` . |
133- | ` getPackagesSync(cwd?) ` | Sync export from ` @manypkg/get-packages ` . |
134- | ` outputEntryBuilder(rootDir, options?) ` | Builds tsdown entry objects by scanning files; ` entries: "index" ` keeps only index files. |
135- | ` pathExists(path) ` | Async ` fs.access ` existence check. |
136- | ` pathExistsSync(path) ` | Sync ` fs.accessSync ` existence check. |
137- | ` require ` | ` createRequire(import.meta.url) ` for ESM modules that need Node require. |
138- | ` unifiedSpawn(command, args?, options?) ` | Cross-platform ` spawn ` wrapper. |
139- | ` unifiedSpawnAsync(command, args?, options?) ` | Promise wrapper resolving the child close code. |
140- | ` unifiedSpawnSync(command, args?, options?) ` | Cross-platform ` spawnSync ` wrapper. |
141- | ` userHome ` | Current ` os.homedir() ` value. |
146+ | Export | Description |
147+ | ---------------------------------------------- | ------------------------------------------------------------------------------------------------ |
148+ | ` appExists(app, options?) ` | Async PATH probe for an executable app. |
149+ | ` appExistsSync(app, options?) ` | Sync PATH probe for an executable app. |
150+ | ` checkProcessDiskAccess(path?) ` | Verifies read/write access for a path, defaulting to ` process.cwd() ` . |
151+ | ` checkProcessDiskUsage(options?) ` | Reads disk usage and returns structured ` checks ` for used-percent and available-byte thresholds. |
152+ | ` checkProcessMemoryUsage(options?) ` | Reads process memory usage and compares heap/RSS usage with optional byte thresholds. |
153+ | ` executeCommand(command, args?, options?) ` | Runs a command and resolves exit details when it succeeds. |
154+ | ` executeCommandSync(command, args?, options?) ` | Sync command runner with the same success/error behavior. |
155+ | ` formatPath(path) ` | Converts backslash separators to ` / ` while leaving Unix paths unchanged. |
156+ | ` createProcessGracefulExit(logger?) ` | Creates isolated process signal registration and shutdown helpers. |
157+ | ` exitSignals ` | Supported graceful shutdown signals: ` SIGINT ` , ` SIGQUIT ` , ` SIGTERM ` . |
158+ | ` getLocalhostAddress() ` | Returns non-internal IPv4 addresses plus ` [::] ` , with duplicates removed. |
159+ | ` getPackages(cwd?) ` | Async export from ` @manypkg/get-packages ` . |
160+ | ` getPackagesSync(cwd?) ` | Sync export from ` @manypkg/get-packages ` . |
161+ | ` getProcessDiskUsage(options?) ` | Reads filesystem capacity, free, available, used bytes, and used percent for a path. |
162+ | ` getProcessMemoryUsage() ` | Reads ` process.memoryUsage() ` with byte-oriented field names. |
163+ | ` outputEntryBuilder(rootDir, options?) ` | Builds tsdown entry objects by scanning files; ` entries: "index" ` keeps only index files. |
164+ | ` pathExists(path) ` | Async ` fs.access ` existence check. |
165+ | ` pathExistsSync(path) ` | Sync ` fs.accessSync ` existence check. |
166+ | ` require ` | ` createRequire(import.meta.url) ` for ESM modules that need Node require. |
167+ | ` unifiedSpawn(command, args?, options?) ` | Cross-platform ` spawn ` wrapper. |
168+ | ` unifiedSpawnAsync(command, args?, options?) ` | Promise wrapper resolving the child close code. |
169+ | ` unifiedSpawnSync(command, args?, options?) ` | Cross-platform ` spawnSync ` wrapper. |
170+ | ` userHome ` | Current ` os.homedir() ` value. |
142171
143172## Runtime Notes
144173
0 commit comments