@pify/shell-background 0.4.0 → 0.4.1
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/src/registry.ts +3 -2
- package/src/spawn.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pify/shell-background",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Long-running bash goes async: background: true launches detached, and any command still running after 30s auto-backgrounds and delivers its result when it finishes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
package/src/registry.ts
CHANGED
|
@@ -44,7 +44,8 @@ export class JobRegistry {
|
|
|
44
44
|
|
|
45
45
|
constructor(baseDir: string) {
|
|
46
46
|
this.baseDir = baseDir;
|
|
47
|
-
|
|
47
|
+
// Logs and sidecars carry command output and cwd paths: the user's eyes only.
|
|
48
|
+
mkdirSync(join(baseDir, "logs"), { recursive: true, mode: 0o700 });
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
/** The directory this registry's sidecars and logs live under. */
|
|
@@ -93,7 +94,7 @@ export class JobRegistry {
|
|
|
93
94
|
try {
|
|
94
95
|
const file = join(this.baseDir, `${job.id}.json`);
|
|
95
96
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
96
|
-
writeFileSync(tmp, JSON.stringify(job));
|
|
97
|
+
writeFileSync(tmp, JSON.stringify(job), { mode: 0o600 });
|
|
97
98
|
renameSync(tmp, file);
|
|
98
99
|
} catch {
|
|
99
100
|
// A registry we cannot persist still works for the live session.
|
package/src/spawn.ts
CHANGED
|
@@ -40,7 +40,9 @@ export function spawnToFile(
|
|
|
40
40
|
logPath: string,
|
|
41
41
|
): Spawned {
|
|
42
42
|
// Append so a re-attach or racing read never clips output already written.
|
|
43
|
-
|
|
43
|
+
// Command output can carry private data, so the log is readable by the user
|
|
44
|
+
// only (pi 1.0.3 does the same for its own output files; a no-op on Windows).
|
|
45
|
+
const out = createWriteStream(logPath, { flags: "a", mode: 0o600 });
|
|
44
46
|
// A write stream with no 'error' listener turns any disk error (ENOSPC,
|
|
45
47
|
// EACCES) or a stray write-after-end into an uncaught exception that takes the
|
|
46
48
|
// whole pi host down. Losing a log line is survivable; crashing the host is
|