@dotcom-tool-kit/node 4.3.3 → 4.4.0

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.
@@ -1,4 +1,5 @@
1
1
  import { Task, TaskRunContext } from '@dotcom-tool-kit/base';
2
+ import { ChildProcess } from 'child_process';
2
3
  import * as z from 'zod';
3
4
  declare const NodeSchema: z.ZodObject<{
4
5
  entry: z.ZodDefault<z.ZodString>;
@@ -23,6 +24,8 @@ export { NodeSchema as schema };
23
24
  export default class Node extends Task<{
24
25
  task: typeof NodeSchema;
25
26
  }> {
27
+ child?: ChildProcess;
26
28
  run({ cwd, config }: TaskRunContext): Promise<void>;
29
+ stop(): Promise<void>;
27
30
  }
28
31
  //# sourceMappingURL=node.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/tasks/node.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAM5D,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;EAqB+C,CAAA;AAC/D,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,CAAA;AAE/B,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,IAAI,CAAC;IAAE,IAAI,EAAE,OAAO,UAAU,CAAA;CAAE,CAAC;IAC3D,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAuD1D"}
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/tasks/node.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAE5D,OAAO,EAAE,YAAY,EAAQ,MAAM,eAAe,CAAA;AAIlD,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;EAqB+C,CAAA;AAC/D,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,CAAA;AAE/B,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,IAAI,CAAC;IAAE,IAAI,EAAE,OAAO,UAAU,CAAA;CAAE,CAAC;IACjE,KAAK,CAAC,EAAE,YAAY,CAAA;IAEd,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAwDnD,IAAI;CAMX"}
package/lib/tasks/node.js CHANGED
@@ -31,6 +31,7 @@ const NodeSchema = z
31
31
  .describe('Run a Node.js application for local development.');
32
32
  exports.schema = NodeSchema;
33
33
  class Node extends base_1.Task {
34
+ child;
34
35
  async run({ cwd, config }) {
35
36
  const { entry, args, useDoppler, ports } = this.options;
36
37
  let dopplerEnv = {};
@@ -49,7 +50,7 @@ class Node extends base_1.Task {
49
50
  }))
50
51
  : false;
51
52
  this.logger.verbose('starting the child node process...');
52
- const child = (0, child_process_1.fork)(path_1.default.resolve(cwd, entry), args, {
53
+ this.child = (0, child_process_1.fork)(path_1.default.resolve(cwd, entry), args, {
53
54
  env: {
54
55
  ...dopplerEnv,
55
56
  PORT: port.toString(),
@@ -59,7 +60,7 @@ class Node extends base_1.Task {
59
60
  silent: true,
60
61
  cwd
61
62
  });
62
- (0, logger_1.hookFork)(this.logger, entry, child);
63
+ (0, logger_1.hookFork)(this.logger, entry, this.child);
63
64
  if (port) {
64
65
  const unhook = (0, logger_1.hookConsole)(this.logger, 'wait-port');
65
66
  try {
@@ -74,5 +75,11 @@ class Node extends base_1.Task {
74
75
  (0, state_1.writeState)('local', { port });
75
76
  }
76
77
  }
78
+ async stop() {
79
+ if (this.child && (this.child.exitCode === null || !this.child.killed)) {
80
+ // SIGINT instead of SIGKILL so the process gets chance to exit gracefully
81
+ this.child.kill('SIGINT');
82
+ }
83
+ }
77
84
  }
78
85
  exports.default = Node;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcom-tool-kit/node",
3
- "version": "4.3.3",
3
+ "version": "4.4.0",
4
4
  "description": "",
5
5
  "main": "lib",
6
6
  "scripts": {
@@ -10,14 +10,14 @@
10
10
  "author": "FT.com Platforms Team <platforms-team.customer-products@ft.com>",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@dotcom-tool-kit/base": "^1.2.2",
14
- "@dotcom-tool-kit/doppler": "^2.2.2",
13
+ "@dotcom-tool-kit/base": "^1.3.0",
14
+ "@dotcom-tool-kit/doppler": "^2.2.3",
15
15
  "@dotcom-tool-kit/error": "^4.1.1",
16
16
  "@dotcom-tool-kit/state": "^4.3.2",
17
17
  "get-port": "^5.1.1",
18
18
  "tslib": "^2.8.1",
19
19
  "wait-port": "^1.1.0",
20
- "zod": "^3.24.3"
20
+ "zod": "^3.24.4"
21
21
  },
22
22
  "repository": {
23
23
  "type": "git",