@jsenv/test 3.5.2 → 3.5.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.
@@ -5464,7 +5464,7 @@ const pingServer = async (url) => {
5464
5464
 
5465
5465
  const startServerUsingCommand = async (
5466
5466
  webServer,
5467
- { signal, allocatedMs, logger, teardownCallbackSet },
5467
+ { signal, allocatedMs, logger, teardownCallbackSet, shell = true },
5468
5468
  ) => {
5469
5469
  const spawnedProcess = spawn(webServer.command, [], {
5470
5470
  // On non-windows platforms, `detached: true` makes child process a leader of a new
@@ -5472,7 +5472,7 @@ const startServerUsingCommand = async (
5472
5472
  // @see https://nodejs.org/api/child_process.html#child_process_options_detached
5473
5473
  detached: process.platform !== "win32",
5474
5474
  stdio: ["pipe", "pipe", "pipe"],
5475
- shell: true,
5475
+ shell,
5476
5476
  cwd: webServer.cwd,
5477
5477
  });
5478
5478
  if (!spawnedProcess.pid) {
@@ -5502,6 +5502,10 @@ const startServerUsingCommand = async (
5502
5502
  let isAbort = false;
5503
5503
  let isTeardown = false;
5504
5504
  let processClosed = false;
5505
+ let stderr = "";
5506
+ spawnedProcess.stderr.on("data", (data) => {
5507
+ stderr += String(data);
5508
+ });
5505
5509
  const closedPromise = new Promise((resolve) => {
5506
5510
  spawnedProcess.once("exit", (exitCode, signal) => {
5507
5511
  processClosed = true;
@@ -5511,7 +5515,10 @@ const startServerUsingCommand = async (
5511
5515
  );
5512
5516
  } else {
5513
5517
  logger.error(
5514
- `web server process premature exit exitCode=${exitCode}, exitSignal=${signal}, pid=${spawnedProcess.pid}`,
5518
+ `web server process premature exit exitCode=${exitCode}, exitSignal=${signal}, pid=${spawnedProcess.pid}
5519
+ --- stderr ---
5520
+ ${stderr}
5521
+ --------------`,
5515
5522
  );
5516
5523
  }
5517
5524
  resolve();
@@ -5612,7 +5619,8 @@ const startServerUsingModuleUrl = async (webServer, params) => {
5612
5619
  return startServerUsingCommand(
5613
5620
  {
5614
5621
  ...webServer,
5615
- command: `node ${fileURLToPath(webServer.moduleUrl)}`,
5622
+ command: `node ${fileURLToPath(webServer.moduleUrl)} --jsenv-test`,
5623
+ shell: false,
5616
5624
  },
5617
5625
  params,
5618
5626
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/test",
3
- "version": "3.5.2",
3
+ "version": "3.5.3",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -4,7 +4,7 @@ import { pingServer } from "../../helpers/ping_server.js";
4
4
 
5
5
  export const startServerUsingCommand = async (
6
6
  webServer,
7
- { signal, allocatedMs, logger, teardownCallbackSet },
7
+ { signal, allocatedMs, logger, teardownCallbackSet, shell = true },
8
8
  ) => {
9
9
  const spawnedProcess = spawn(webServer.command, [], {
10
10
  // On non-windows platforms, `detached: true` makes child process a leader of a new
@@ -12,7 +12,7 @@ export const startServerUsingCommand = async (
12
12
  // @see https://nodejs.org/api/child_process.html#child_process_options_detached
13
13
  detached: process.platform !== "win32",
14
14
  stdio: ["pipe", "pipe", "pipe"],
15
- shell: true,
15
+ shell,
16
16
  cwd: webServer.cwd,
17
17
  });
18
18
  if (!spawnedProcess.pid) {
@@ -42,6 +42,10 @@ export const startServerUsingCommand = async (
42
42
  let isAbort = false;
43
43
  let isTeardown = false;
44
44
  let processClosed = false;
45
+ let stderr = "";
46
+ spawnedProcess.stderr.on("data", (data) => {
47
+ stderr += String(data);
48
+ });
45
49
  const closedPromise = new Promise((resolve) => {
46
50
  spawnedProcess.once("exit", (exitCode, signal) => {
47
51
  processClosed = true;
@@ -51,7 +55,10 @@ export const startServerUsingCommand = async (
51
55
  );
52
56
  } else {
53
57
  logger.error(
54
- `web server process premature exit exitCode=${exitCode}, exitSignal=${signal}, pid=${spawnedProcess.pid}`,
58
+ `web server process premature exit exitCode=${exitCode}, exitSignal=${signal}, pid=${spawnedProcess.pid}
59
+ --- stderr ---
60
+ ${stderr}
61
+ --------------`,
55
62
  );
56
63
  }
57
64
  resolve();
@@ -10,7 +10,8 @@ export const startServerUsingModuleUrl = async (webServer, params) => {
10
10
  return startServerUsingCommand(
11
11
  {
12
12
  ...webServer,
13
- command: `node ${fileURLToPath(webServer.moduleUrl)}`,
13
+ command: `node ${fileURLToPath(webServer.moduleUrl)} --jsenv-test`,
14
+ shell: false,
14
15
  },
15
16
  params,
16
17
  );