daemonize-process 4.1.0 → 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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) silverwind
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
17
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- import { SpawnOptions } from 'node:child_process';
2
-
1
+ import { SpawnOptions } from "node:child_process";
2
+ //#region index.d.ts
3
3
  type DaemonizeProcessOpts = {
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;
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;
12
12
  } & SpawnOptions;
13
13
  export declare function daemonizeProcess(opts?: DaemonizeProcessOpts): void;
14
- export {};
14
+ //#endregion
package/dist/index.js CHANGED
@@ -1,29 +1,27 @@
1
- import { spawn } from 'node:child_process';
2
- import { env, cwd, execPath, argv, exit } from 'node:process';
1
+ import { spawn } from "node:child_process";
2
+ import { argv, cwd, env, execPath, exit } from "node:process";
3
3
 
4
+ //#region index.ts
4
5
  const id = "_DAEMONIZE_PROCESS";
5
6
  function daemonizeProcess(opts = {}) {
6
- if (id in env) {
7
- delete env[id];
8
- } else {
9
- const o = {
10
- // spawn options
11
- env: Object.assign(env, opts.env, { [id]: "1" }),
12
- cwd: cwd(),
13
- stdio: "ignore",
14
- detached: true,
15
- // custom options
16
- node: execPath,
17
- script: argv[1],
18
- arguments: argv.slice(2),
19
- exitCode: 0,
20
- ...opts
21
- };
22
- const args = [o.script, ...o.arguments];
23
- const proc = spawn(o.node, args, o);
24
- proc?.unref?.();
25
- exit(o.exitCode);
26
- }
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
+ }
27
24
  }
28
25
 
29
- export { daemonizeProcess };
26
+ //#endregion
27
+ export { daemonizeProcess };
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "daemonize-process",
3
- "version": "4.1.0",
3
+ "version": "4.1.3",
4
4
  "description": "Daemonize the current Node.js process",
5
5
  "author": "silverwind <me@silverwind.io>",
6
- "repository": "silverwind/daemonize-process",
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,19 +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": "20.12.12",
21
- "eslint": "8.57.0",
22
- "eslint-config-silverwind": "85.1.4",
23
- "eslint-config-silverwind-typescript": "3.2.7",
24
- "typescript": "5.4.5",
25
- "typescript-config-silverwind": "4.3.2",
26
- "updates": "16.1.1",
27
- "versions": "12.0.2",
28
- "vite": "5.2.11",
29
- "vite-config-silverwind": "1.1.2",
30
- "vite-plugin-dts": "3.9.1"
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"
31
37
  }
32
- }
38
+ }