daemonize-process 4.1.1 → 4.1.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/dist/index.d.ts +11 -11
- package/dist/index.js +23 -25
- package/package.json +21 -16
- package/dist/index.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { SpawnOptions } from
|
|
1
|
+
import { SpawnOptions } from "node:child_process";
|
|
2
|
+
//#region index.d.ts
|
|
2
3
|
type DaemonizeProcessOpts = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
/** The path to the script to be executed. Default: The current script. */
|
|
5
|
+
script?: string;
|
|
6
|
+
/** The command line arguments to be used. Default: The current arguments. */
|
|
7
|
+
arguments?: string[];
|
|
8
|
+
/** The path to the Node.js binary to be used. Default: The current Node.js binary. */
|
|
9
|
+
node?: string;
|
|
10
|
+
/** The exit code to be used when exiting the parent process. Default: `0`. */
|
|
11
|
+
exitCode?: number;
|
|
11
12
|
} & SpawnOptions;
|
|
12
13
|
export declare function daemonizeProcess(opts?: DaemonizeProcessOpts): void;
|
|
13
|
-
|
|
14
|
-
//# sourceMappingURL=index.d.ts.map
|
|
14
|
+
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -1,29 +1,27 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
-
import {
|
|
2
|
+
import { argv, cwd, env, execPath, exit } from "node:process";
|
|
3
|
+
|
|
4
|
+
//#region index.ts
|
|
3
5
|
const id = "_DAEMONIZE_PROCESS";
|
|
4
6
|
function daemonizeProcess(opts = {}) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const proc = spawn(o.node, args, o);
|
|
23
|
-
proc?.unref?.();
|
|
24
|
-
exit(o.exitCode);
|
|
25
|
-
}
|
|
7
|
+
if (id in env) delete env[id];
|
|
8
|
+
else {
|
|
9
|
+
const o = {
|
|
10
|
+
env: Object.assign(env, opts.env, { [id]: "1" }),
|
|
11
|
+
cwd: cwd(),
|
|
12
|
+
stdio: "ignore",
|
|
13
|
+
detached: true,
|
|
14
|
+
node: execPath,
|
|
15
|
+
script: argv[1],
|
|
16
|
+
arguments: argv.slice(2),
|
|
17
|
+
exitCode: 0,
|
|
18
|
+
...opts
|
|
19
|
+
};
|
|
20
|
+
const args = [o.script, ...o.arguments];
|
|
21
|
+
spawn(o.node, args, o)?.unref?.();
|
|
22
|
+
exit(o.exitCode);
|
|
23
|
+
}
|
|
26
24
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { daemonizeProcess };
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "daemonize-process",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.3",
|
|
4
4
|
"description": "Daemonize the current Node.js process",
|
|
5
5
|
"author": "silverwind <me@silverwind.io>",
|
|
6
|
-
"repository":
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/silverwind/daemonize-process.git"
|
|
9
|
+
},
|
|
7
10
|
"license": "BSD-2-Clause",
|
|
8
11
|
"type": "module",
|
|
9
12
|
"sideEffects": false,
|
|
@@ -14,20 +17,22 @@
|
|
|
14
17
|
"dist"
|
|
15
18
|
],
|
|
16
19
|
"engines": {
|
|
17
|
-
"node": ">=18"
|
|
20
|
+
"node": ">=18",
|
|
21
|
+
"bun": "*"
|
|
18
22
|
},
|
|
19
23
|
"devDependencies": {
|
|
20
|
-
"@types/node": "
|
|
21
|
-
"
|
|
22
|
-
"eslint
|
|
23
|
-
"eslint-config-silverwind
|
|
24
|
-
"jest-extended": "
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
24
|
+
"@types/node": "26.6.2",
|
|
25
|
+
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
26
|
+
"eslint": "9.39.2",
|
|
27
|
+
"eslint-config-silverwind": "151.0.0",
|
|
28
|
+
"jest-extended": "7.0.0",
|
|
29
|
+
"tsdown": "0.23.0",
|
|
30
|
+
"tsdown-config-silverwind": "4.1.1",
|
|
31
|
+
"typescript": "6.0.3",
|
|
32
|
+
"typescript-config-silverwind": "21.0.0",
|
|
33
|
+
"updates": "19.0.0",
|
|
34
|
+
"updates-config-silverwind": "4.0.6",
|
|
35
|
+
"versions": "15.5.0",
|
|
36
|
+
"vitest": "5.0.2"
|
|
32
37
|
}
|
|
33
|
-
}
|
|
38
|
+
}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAIrD,KAAK,oBAAoB,GAAG;IAC1B,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,sFAAsF;IACtF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,YAAY,CAAC;AAEjB,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,oBAAyB,QAyB/D"}
|