@oh-my-pi/pi-utils 18.13.2 → 18.13.3
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/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/dist/types/index.d.ts +0 -1
- package/package.json +3 -3
- package/src/index.ts +0 -1
- package/src/logger/rotating-file.ts +1 -2
- package/dist/types/fs-open.d.ts +0 -17
- package/src/fs-open.ts +0 -32
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ Import from the root barrel or per-module subpaths (`@oh-my-pi/pi-utils/<module>
|
|
|
29
29
|
bun add @oh-my-pi/pi-utils
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
Ships TypeScript source directly (no build step); requires Bun ≥ 1.
|
|
32
|
+
Ships TypeScript source directly (no build step); requires Bun ≥ 1.4.4.
|
|
33
33
|
|
|
34
34
|
## References
|
|
35
35
|
|
package/dist/types/index.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ export * from "./file-lock.js";
|
|
|
10
10
|
export * from "./format.js";
|
|
11
11
|
export * from "./frontmatter.js";
|
|
12
12
|
export * from "./fs-error.js";
|
|
13
|
-
export * from "./fs-open.js";
|
|
14
13
|
export * from "./incoming-json.js";
|
|
15
14
|
export * from "./json.js";
|
|
16
15
|
export * from "./json-parse.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oh-my-pi/pi-utils",
|
|
3
|
-
"version": "18.13.
|
|
3
|
+
"version": "18.13.3",
|
|
4
4
|
"description": "Shared utilities for pi packages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
"fmt": "oxfmt --no-error-on-unmatched-pattern 'src/**/*.{ts,tsx}' '{test,bench,examples,scripts}/**/*.ts' '*.ts'"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@oh-my-pi/pi-natives": "18.13.
|
|
60
|
+
"@oh-my-pi/pi-natives": "18.13.3"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/bun": "^1.3.14"
|
|
64
64
|
},
|
|
65
65
|
"engines": {
|
|
66
|
-
"bun": ">=1.
|
|
66
|
+
"bun": ">=1.4.4"
|
|
67
67
|
}
|
|
68
68
|
}
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,6 @@ import * as fs from "node:fs";
|
|
|
3
3
|
import * as os from "node:os";
|
|
4
4
|
import * as path from "node:path";
|
|
5
5
|
import { localDay } from "../dirs";
|
|
6
|
-
import { openCloexecSync } from "../fs-open";
|
|
7
6
|
|
|
8
7
|
/** Write batching for {@link RotatingFileSink}. */
|
|
9
8
|
export interface RotatingFileBatchOptions {
|
|
@@ -87,7 +86,7 @@ export class RotatingFileSink {
|
|
|
87
86
|
|
|
88
87
|
#openFd(filePath: string): void {
|
|
89
88
|
this.#closeFd();
|
|
90
|
-
this.#fd =
|
|
89
|
+
this.#fd = fs.openSync(filePath, fs.constants.O_WRONLY | fs.constants.O_CREAT | fs.constants.O_APPEND);
|
|
91
90
|
try {
|
|
92
91
|
this.#onRotate?.(filePath);
|
|
93
92
|
} catch {
|
package/dist/types/fs-open.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `fs.openSync` with close-on-exec, matching Node's default.
|
|
3
|
-
*
|
|
4
|
-
* libuv adds `O_CLOEXEC` inside `uv__fs_open`, so on Node every `fs` descriptor
|
|
5
|
-
* dies at `exec`. Bun's `fs.open*` did not before 1.4.3 (still allowed by the
|
|
6
|
-
* `bun@>=1.4` pin), and descriptors it returns survive
|
|
7
|
-
* into any child spawned through a path that does not close strays itself — the
|
|
8
|
-
* bash tool's shell `fork`/`exec`s user commands and hands them the lot. Use
|
|
9
|
-
* this for every descriptor kept open past such a spawn (session transcripts,
|
|
10
|
-
* logs, spools); a child must never hold a writable handle to them (#13224).
|
|
11
|
-
*
|
|
12
|
-
* Flags are numeric only: the bit cannot be OR-ed into `"a"`/`"w+"` strings.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* const fd = openCloexecSync(logPath, fs.constants.O_WRONLY | fs.constants.O_CREAT | fs.constants.O_APPEND);
|
|
16
|
-
*/
|
|
17
|
-
export declare function openCloexecSync(filePath: string, flags: number, mode?: number): number;
|
package/src/fs-open.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/** Close-on-exec file opens for descriptors held past a child spawn. */
|
|
2
|
-
import * as fs from "node:fs";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* `O_CLOEXEC`, which neither Node nor Bun exposes in `fs.constants`.
|
|
6
|
-
*
|
|
7
|
-
* Kernel ABI values: `0o2000000` on Linux, `0x0100_0000` on Darwin. Windows has
|
|
8
|
-
* no `exec` and its CRT handles are inherited only when a spawn explicitly asks
|
|
9
|
-
* for it, so the bit is 0 there — as it is on any other platform, where adding
|
|
10
|
-
* an unknown flag bit would be worse than leaving the descriptor inheritable.
|
|
11
|
-
*/
|
|
12
|
-
const O_CLOEXEC = process.platform === "linux" ? 0o2000000 : process.platform === "darwin" ? 0x0100_0000 : 0;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* `fs.openSync` with close-on-exec, matching Node's default.
|
|
16
|
-
*
|
|
17
|
-
* libuv adds `O_CLOEXEC` inside `uv__fs_open`, so on Node every `fs` descriptor
|
|
18
|
-
* dies at `exec`. Bun's `fs.open*` did not before 1.4.3 (still allowed by the
|
|
19
|
-
* `bun@>=1.4` pin), and descriptors it returns survive
|
|
20
|
-
* into any child spawned through a path that does not close strays itself — the
|
|
21
|
-
* bash tool's shell `fork`/`exec`s user commands and hands them the lot. Use
|
|
22
|
-
* this for every descriptor kept open past such a spawn (session transcripts,
|
|
23
|
-
* logs, spools); a child must never hold a writable handle to them (#13224).
|
|
24
|
-
*
|
|
25
|
-
* Flags are numeric only: the bit cannot be OR-ed into `"a"`/`"w+"` strings.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* const fd = openCloexecSync(logPath, fs.constants.O_WRONLY | fs.constants.O_CREAT | fs.constants.O_APPEND);
|
|
29
|
-
*/
|
|
30
|
-
export function openCloexecSync(filePath: string, flags: number, mode?: number): number {
|
|
31
|
-
return fs.openSync(filePath, flags | O_CLOEXEC, mode);
|
|
32
|
-
}
|