@jsenv/test 3.5.45 → 3.6.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.
@@ -3,8 +3,8 @@ import os, { cpus, release, totalmem, availableParallelism, freemem } from "node
3
3
  import tty from "node:tty";
4
4
  import stringWidth from "string-width";
5
5
  import { pathToFileURL, fileURLToPath } from "node:url";
6
- import { URL_META, filterV8Coverage } from "./js/v8_coverage.js";
7
6
  import { readdir, chmod, stat, lstat, chmodSync, statSync, lstatSync, promises, readFile as readFile$1, unlinkSync, openSync, closeSync, readdirSync, rmdirSync, mkdirSync, readFileSync, writeFileSync as writeFileSync$1, unlink, rmdir, existsSync } from "node:fs";
7
+ import { URL_META, filterV8Coverage } from "./js/v8_coverage.js";
8
8
  import { dirname } from "node:path";
9
9
  import crypto from "node:crypto";
10
10
  import { readGitHubWorkflowEnv, startGithubCheckRun } from "@jsenv/github-check-run";
@@ -531,24 +531,6 @@ const SIGINT_CALLBACK = {
531
531
  },
532
532
  };
533
533
 
534
- const createDetailedMessage = (message, details = {}) => {
535
- let string = `${message}`;
536
-
537
- Object.keys(details).forEach((key) => {
538
- const value = details[key];
539
- string += `
540
- --- ${key} ---
541
- ${
542
- Array.isArray(value)
543
- ? value.join(`
544
- `)
545
- : value
546
- }`;
547
- });
548
-
549
- return string;
550
- };
551
-
552
534
  // From: https://github.com/sindresorhus/has-flag/blob/main/index.js
553
535
  /// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {
554
536
  function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process$1.argv) {
@@ -738,6 +720,125 @@ function createSupportsColor(stream, options = {}) {
738
720
  stderr: createSupportsColor({isTTY: tty.isatty(2)}),
739
721
  });
740
722
 
723
+ function isUnicodeSupported() {
724
+ const {env} = process$1;
725
+ const {TERM, TERM_PROGRAM} = env;
726
+
727
+ if (process$1.platform !== 'win32') {
728
+ return TERM !== 'linux'; // Linux console (kernel)
729
+ }
730
+
731
+ return Boolean(env.WT_SESSION) // Windows Terminal
732
+ || Boolean(env.TERMINUS_SUBLIME) // Terminus (<0.2.27)
733
+ || env.ConEmuTask === '{cmd::Cmder}' // ConEmu and cmder
734
+ || TERM_PROGRAM === 'Terminus-Sublime'
735
+ || TERM_PROGRAM === 'vscode'
736
+ || TERM === 'xterm-256color'
737
+ || TERM === 'alacritty'
738
+ || TERM === 'rxvt-unicode'
739
+ || TERM === 'rxvt-unicode-256color'
740
+ || env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
741
+ }
742
+
743
+ /* globals WorkerGlobalScope, DedicatedWorkerGlobalScope, SharedWorkerGlobalScope, ServiceWorkerGlobalScope */
744
+
745
+ const isBrowser = globalThis.window?.document !== undefined;
746
+
747
+ globalThis.process?.versions?.node !== undefined;
748
+
749
+ globalThis.process?.versions?.bun !== undefined;
750
+
751
+ globalThis.Deno?.version?.deno !== undefined;
752
+
753
+ globalThis.process?.versions?.electron !== undefined;
754
+
755
+ globalThis.navigator?.userAgent?.includes('jsdom') === true;
756
+
757
+ typeof WorkerGlobalScope !== 'undefined' && globalThis instanceof WorkerGlobalScope;
758
+
759
+ typeof DedicatedWorkerGlobalScope !== 'undefined' && globalThis instanceof DedicatedWorkerGlobalScope;
760
+
761
+ typeof SharedWorkerGlobalScope !== 'undefined' && globalThis instanceof SharedWorkerGlobalScope;
762
+
763
+ typeof ServiceWorkerGlobalScope !== 'undefined' && globalThis instanceof ServiceWorkerGlobalScope;
764
+
765
+ // Note: I'm intentionally not DRYing up the other variables to keep them "lazy".
766
+ const platform = globalThis.navigator?.userAgentData?.platform;
767
+
768
+ platform === 'macOS'
769
+ || globalThis.navigator?.platform === 'MacIntel' // Even on Apple silicon Macs.
770
+ || globalThis.navigator?.userAgent?.includes(' Mac ') === true
771
+ || globalThis.process?.platform === 'darwin';
772
+
773
+ platform === 'Windows'
774
+ || globalThis.navigator?.platform === 'Win32'
775
+ || globalThis.process?.platform === 'win32';
776
+
777
+ platform === 'Linux'
778
+ || globalThis.navigator?.platform?.startsWith('Linux') === true
779
+ || globalThis.navigator?.userAgent?.includes(' Linux ') === true
780
+ || globalThis.process?.platform === 'linux';
781
+
782
+ platform === 'Android'
783
+ || globalThis.navigator?.platform === 'Android'
784
+ || globalThis.navigator?.userAgent?.includes(' Android ') === true
785
+ || globalThis.process?.platform === 'android';
786
+
787
+ const ESC = '\u001B[';
788
+
789
+ !isBrowser && process$1.env.TERM_PROGRAM === 'Apple_Terminal';
790
+ const isWindows$3 = !isBrowser && process$1.platform === 'win32';
791
+
792
+ isBrowser ? () => {
793
+ throw new Error('`process.cwd()` only works in Node.js, not the browser.');
794
+ } : process$1.cwd;
795
+
796
+ const cursorUp = (count = 1) => ESC + count + 'A';
797
+
798
+ const cursorLeft = ESC + 'G';
799
+
800
+ const eraseLines = count => {
801
+ let clear = '';
802
+
803
+ for (let i = 0; i < count; i++) {
804
+ clear += eraseLine + (i < count - 1 ? cursorUp() : '');
805
+ }
806
+
807
+ if (count) {
808
+ clear += cursorLeft;
809
+ }
810
+
811
+ return clear;
812
+ };
813
+ const eraseLine = ESC + '2K';
814
+ const eraseScreen = ESC + '2J';
815
+
816
+ const clearTerminal = isWindows$3
817
+ ? `${eraseScreen}${ESC}0f`
818
+ // 1. Erases the screen (Only done in case `2` is not supported)
819
+ // 2. Erases the whole screen including scrollback buffer
820
+ // 3. Moves cursor to the top-left position
821
+ // More info: https://www.real-world-systems.com/docs/ANSIcode.html
822
+ : `${eraseScreen}${ESC}3J${ESC}H`;
823
+
824
+ const createDetailedMessage = (message, details = {}) => {
825
+ let string = `${message}`;
826
+
827
+ Object.keys(details).forEach((key) => {
828
+ const value = details[key];
829
+ string += `
830
+ --- ${key} ---
831
+ ${
832
+ Array.isArray(value)
833
+ ? value.join(`
834
+ `)
835
+ : value
836
+ }`;
837
+ });
838
+
839
+ return string;
840
+ };
841
+
741
842
  // https://github.com/Marak/colors.js/blob/master/lib/styles.js
742
843
  // https://stackoverflow.com/a/75985833/2634179
743
844
  const RESET = "\x1b[0m";
@@ -799,26 +900,6 @@ const ANSI = createAnsi({
799
900
  process.env.GITHUB_WORKFLOW,
800
901
  });
801
902
 
802
- function isUnicodeSupported() {
803
- const {env} = process$1;
804
- const {TERM, TERM_PROGRAM} = env;
805
-
806
- if (process$1.platform !== 'win32') {
807
- return TERM !== 'linux'; // Linux console (kernel)
808
- }
809
-
810
- return Boolean(env.WT_SESSION) // Windows Terminal
811
- || Boolean(env.TERMINUS_SUBLIME) // Terminus (<0.2.27)
812
- || env.ConEmuTask === '{cmd::Cmder}' // ConEmu and cmder
813
- || TERM_PROGRAM === 'Terminus-Sublime'
814
- || TERM_PROGRAM === 'vscode'
815
- || TERM === 'xterm-256color'
816
- || TERM === 'alacritty'
817
- || TERM === 'rxvt-unicode'
818
- || TERM === 'rxvt-unicode-256color'
819
- || env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
820
- }
821
-
822
903
  // see also https://github.com/sindresorhus/figures
823
904
 
824
905
  const createUnicode = ({ supported, ANSI }) => {
@@ -932,23 +1013,6 @@ const setDecimalsPrecision = (
932
1013
  const asFloat = asInteger / coef;
933
1014
  return number < 0 ? -asFloat : asFloat;
934
1015
  };
935
-
936
- // https://www.codingem.com/javascript-how-to-limit-decimal-places/
937
- // export const roundNumber = (number, maxDecimals) => {
938
- // const decimalsExp = Math.pow(10, maxDecimals)
939
- // const numberRoundInt = Math.round(decimalsExp * (number + Number.EPSILON))
940
- // const numberRoundFloat = numberRoundInt / decimalsExp
941
- // return numberRoundFloat
942
- // }
943
-
944
- // export const setPrecision = (number, precision) => {
945
- // if (Math.floor(number) === number) return number
946
- // const [int, decimals] = number.toString().split(".")
947
- // if (precision <= 0) return int
948
- // const numberTruncated = `${int}.${decimals.slice(0, precision)}`
949
- // return numberTruncated
950
- // }
951
-
952
1016
  const unitShort = {
953
1017
  year: "y",
954
1018
  month: "m",
@@ -1359,87 +1423,6 @@ const error = (...args) => console.error(...args);
1359
1423
 
1360
1424
  const errorDisabled = () => {};
1361
1425
 
1362
- /* globals WorkerGlobalScope, DedicatedWorkerGlobalScope, SharedWorkerGlobalScope, ServiceWorkerGlobalScope */
1363
-
1364
- const isBrowser = globalThis.window?.document !== undefined;
1365
-
1366
- globalThis.process?.versions?.node !== undefined;
1367
-
1368
- globalThis.process?.versions?.bun !== undefined;
1369
-
1370
- globalThis.Deno?.version?.deno !== undefined;
1371
-
1372
- globalThis.process?.versions?.electron !== undefined;
1373
-
1374
- globalThis.navigator?.userAgent?.includes('jsdom') === true;
1375
-
1376
- typeof WorkerGlobalScope !== 'undefined' && globalThis instanceof WorkerGlobalScope;
1377
-
1378
- typeof DedicatedWorkerGlobalScope !== 'undefined' && globalThis instanceof DedicatedWorkerGlobalScope;
1379
-
1380
- typeof SharedWorkerGlobalScope !== 'undefined' && globalThis instanceof SharedWorkerGlobalScope;
1381
-
1382
- typeof ServiceWorkerGlobalScope !== 'undefined' && globalThis instanceof ServiceWorkerGlobalScope;
1383
-
1384
- // Note: I'm intentionally not DRYing up the other variables to keep them "lazy".
1385
- const platform = globalThis.navigator?.userAgentData?.platform;
1386
-
1387
- platform === 'macOS'
1388
- || globalThis.navigator?.platform === 'MacIntel' // Even on Apple silicon Macs.
1389
- || globalThis.navigator?.userAgent?.includes(' Mac ') === true
1390
- || globalThis.process?.platform === 'darwin';
1391
-
1392
- platform === 'Windows'
1393
- || globalThis.navigator?.platform === 'Win32'
1394
- || globalThis.process?.platform === 'win32';
1395
-
1396
- platform === 'Linux'
1397
- || globalThis.navigator?.platform?.startsWith('Linux') === true
1398
- || globalThis.navigator?.userAgent?.includes(' Linux ') === true
1399
- || globalThis.process?.platform === 'linux';
1400
-
1401
- platform === 'Android'
1402
- || globalThis.navigator?.platform === 'Android'
1403
- || globalThis.navigator?.userAgent?.includes(' Android ') === true
1404
- || globalThis.process?.platform === 'android';
1405
-
1406
- const ESC = '\u001B[';
1407
-
1408
- !isBrowser && process$1.env.TERM_PROGRAM === 'Apple_Terminal';
1409
- const isWindows$3 = !isBrowser && process$1.platform === 'win32';
1410
-
1411
- isBrowser ? () => {
1412
- throw new Error('`process.cwd()` only works in Node.js, not the browser.');
1413
- } : process$1.cwd;
1414
-
1415
- const cursorUp = (count = 1) => ESC + count + 'A';
1416
-
1417
- const cursorLeft = ESC + 'G';
1418
-
1419
- const eraseLines = count => {
1420
- let clear = '';
1421
-
1422
- for (let i = 0; i < count; i++) {
1423
- clear += eraseLine + (i < count - 1 ? cursorUp() : '');
1424
- }
1425
-
1426
- if (count) {
1427
- clear += cursorLeft;
1428
- }
1429
-
1430
- return clear;
1431
- };
1432
- const eraseLine = ESC + '2K';
1433
- const eraseScreen = ESC + '2J';
1434
-
1435
- const clearTerminal = isWindows$3
1436
- ? `${eraseScreen}${ESC}0f`
1437
- // 1. Erases the screen (Only done in case `2` is not supported)
1438
- // 2. Erases the whole screen including scrollback buffer
1439
- // 3. Moves cursor to the top-left position
1440
- // More info: https://www.real-world-systems.com/docs/ANSIcode.html
1441
- : `${eraseScreen}${ESC}3J${ESC}H`;
1442
-
1443
1426
  /*
1444
1427
  * see also https://github.com/vadimdemedes/ink
1445
1428
  */
@@ -1624,6 +1607,34 @@ const spyStreamOutput = (stream, callback) => {
1624
1607
  };
1625
1608
  };
1626
1609
 
1610
+ const pathnameToExtension = (pathname) => {
1611
+ const slashLastIndex = pathname.lastIndexOf("/");
1612
+ const filename =
1613
+ slashLastIndex === -1 ? pathname : pathname.slice(slashLastIndex + 1);
1614
+ if (filename.match(/@([0-9])+(\.[0-9]+)?(\.[0-9]+)?$/)) {
1615
+ return "";
1616
+ }
1617
+ const dotLastIndex = filename.lastIndexOf(".");
1618
+ if (dotLastIndex === -1) {
1619
+ return "";
1620
+ }
1621
+ // if (dotLastIndex === pathname.length - 1) return ""
1622
+ const extension = filename.slice(dotLastIndex);
1623
+ return extension;
1624
+ };
1625
+
1626
+ const resourceToPathname = (resource) => {
1627
+ const searchSeparatorIndex = resource.indexOf("?");
1628
+ if (searchSeparatorIndex > -1) {
1629
+ return resource.slice(0, searchSeparatorIndex);
1630
+ }
1631
+ const hashIndex = resource.indexOf("#");
1632
+ if (hashIndex > -1) {
1633
+ return resource.slice(0, hashIndex);
1634
+ }
1635
+ return resource;
1636
+ };
1637
+
1627
1638
  const urlToScheme = (url) => {
1628
1639
  const urlString = String(url);
1629
1640
  const colonIndex = urlString.indexOf(":");
@@ -1661,36 +1672,11 @@ const urlToPathname = (url) => {
1661
1672
  return pathname;
1662
1673
  };
1663
1674
 
1664
- const resourceToPathname = (resource) => {
1665
- const searchSeparatorIndex = resource.indexOf("?");
1666
- if (searchSeparatorIndex > -1) {
1667
- return resource.slice(0, searchSeparatorIndex);
1668
- }
1669
- const hashIndex = resource.indexOf("#");
1670
- if (hashIndex > -1) {
1671
- return resource.slice(0, hashIndex);
1672
- }
1673
- return resource;
1674
- };
1675
-
1676
1675
  const urlToExtension = (url) => {
1677
1676
  const pathname = urlToPathname(url);
1678
1677
  return pathnameToExtension(pathname);
1679
1678
  };
1680
1679
 
1681
- const pathnameToExtension = (pathname) => {
1682
- const slashLastIndex = pathname.lastIndexOf("/");
1683
- if (slashLastIndex !== -1) {
1684
- pathname = pathname.slice(slashLastIndex + 1);
1685
- }
1686
-
1687
- const dotLastIndex = pathname.lastIndexOf(".");
1688
- if (dotLastIndex === -1) return "";
1689
- // if (dotLastIndex === pathname.length - 1) return ""
1690
- const extension = pathname.slice(dotLastIndex);
1691
- return extension;
1692
- };
1693
-
1694
1680
  const transformUrlPathname = (url, transformer) => {
1695
1681
  if (typeof url === "string") {
1696
1682
  const urlObject = new URL(url);
@@ -5879,14 +5865,23 @@ const startServerUsingCommand = async (
5879
5865
  }
5880
5866
  };
5881
5867
 
5882
- const startServerUsingModuleUrl = async (webServer, params) => {
5868
+ const startServerUsingModuleUrl = async (
5869
+ webServer,
5870
+ { ignoreProcessExecArgv, ...params },
5871
+ ) => {
5883
5872
  if (!existsSync(new URL(webServer.moduleUrl))) {
5884
5873
  throw new Error(`"${webServer.moduleUrl}" does not lead to a file`);
5885
5874
  }
5875
+ let command = `node`;
5876
+ if (!ignoreProcessExecArgv && process.execArgv.length > 0) {
5877
+ command += ` ${process.execArgv.join(" ")}`;
5878
+ }
5879
+ command += ` ${fileURLToPath(webServer.moduleUrl)}`;
5880
+
5886
5881
  return startServerUsingCommand(
5887
5882
  {
5888
5883
  ...webServer,
5889
- command: `node ${fileURLToPath(webServer.moduleUrl)}`,
5884
+ command,
5890
5885
  args: ["--jsenv-test"],
5891
5886
  },
5892
5887
  params,
@@ -5926,20 +5921,20 @@ const assertAndNormalizeWebServer = async (
5926
5921
  teardownCallbackSet,
5927
5922
  logger,
5928
5923
  });
5929
- const { headers } = await basicFetch(webServer.origin, {
5930
- method: "GET",
5931
- rejectUnauthorized: false,
5932
- headers: {
5933
- "x-server-inspect": "1",
5924
+ const serverJsonResponse = await basicFetch(
5925
+ `${webServer.origin}/.internal/server.json`,
5926
+ {
5927
+ method: "GET",
5928
+ rejectUnauthorized: false,
5934
5929
  },
5935
- });
5936
- if (String(headers["server"]).includes("jsenv_dev_server")) {
5930
+ );
5931
+ if (
5932
+ serverJsonResponse.status === 200 &&
5933
+ String(serverJsonResponse.headers["server"]).includes("jsenv_dev_server")
5934
+ ) {
5937
5935
  webServer.isJsenvDevServer = true;
5938
- const { json } = await basicFetch(`${webServer.origin}/__params__.json`, {
5939
- rejectUnauthorized: false,
5940
- });
5941
5936
  if (webServer.rootDirectoryUrl === undefined) {
5942
- const jsenvDevServerParams = await json();
5937
+ const jsenvDevServerParams = await serverJsonResponse.json();
5943
5938
  webServer.rootDirectoryUrl = jsenvDevServerParams.sourceDirectoryUrl;
5944
5939
  } else {
5945
5940
  webServer.rootDirectoryUrl = assertAndNormalizeDirectoryUrl(
@@ -5957,7 +5952,13 @@ const assertAndNormalizeWebServer = async (
5957
5952
 
5958
5953
  const ensureWebServerIsStarted = async (
5959
5954
  webServer,
5960
- { signal, teardownCallbackSet, logger, allocatedMs = 5_000 },
5955
+ {
5956
+ signal,
5957
+ teardownCallbackSet,
5958
+ logger,
5959
+ allocatedMs = 5_000,
5960
+ ignoreProcessExecArgv,
5961
+ },
5961
5962
  ) => {
5962
5963
  const aServerIsListening = await pingServer(webServer.origin);
5963
5964
  if (aServerIsListening) {
@@ -5965,6 +5966,7 @@ const ensureWebServerIsStarted = async (
5965
5966
  }
5966
5967
  if (webServer.moduleUrl) {
5967
5968
  await startServerUsingModuleUrl(webServer, {
5969
+ ignoreProcessExecArgv,
5968
5970
  signal,
5969
5971
  allocatedMs,
5970
5972
  teardownCallbackSet,
@@ -5974,6 +5976,7 @@ const ensureWebServerIsStarted = async (
5974
5976
  }
5975
5977
  if (webServer.command) {
5976
5978
  await startServerUsingCommand(webServer, {
5979
+ ignoreProcessExecArgv,
5977
5980
  signal,
5978
5981
  allocatedMs,
5979
5982
  teardownCallbackSet,
@@ -8333,7 +8336,7 @@ const EXIT_CODES = {
8333
8336
  };
8334
8337
 
8335
8338
  const IMPORTMAP_NODE_LOADER_FILE_URL = new URL(
8336
- "./importmap_node_loader.mjs",
8339
+ "./js/importmap_node_loader.mjs",
8337
8340
  import.meta.url,
8338
8341
  ).href;
8339
8342
 
@@ -8413,12 +8416,12 @@ const killProcessTree = async (
8413
8416
  };
8414
8417
 
8415
8418
  const NO_EXPERIMENTAL_WARNING_FILE_URL = new URL(
8416
- "./no_experimental_warnings.cjs",
8419
+ "./js/no_experimental_warnings.cjs",
8417
8420
  import.meta.url,
8418
8421
  ).href;
8419
8422
 
8420
8423
  const CONTROLLED_CHILD_PROCESS_URL = new URL(
8421
- "./node_child_process_controlled.mjs",
8424
+ "./js/node_child_process_controlled.mjs",
8422
8425
  import.meta.url,
8423
8426
  ).href;
8424
8427
 
@@ -8906,7 +8909,7 @@ const onceChildProcessEvent = (childProcess, type, callback) => {
8906
8909
  // https://github.com/avajs/ava/blob/576f534b345259055c95fa0c2b33bef10847a2af/lib/worker/base.js
8907
8910
 
8908
8911
  const CONTROLLED_WORKER_THREAD_URL = new URL(
8909
- "./node_worker_thread_controlled.mjs",
8912
+ "./js/node_worker_thread_controlled.mjs",
8910
8913
  import.meta.url,
8911
8914
  ).href;
8912
8915
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/test",
3
- "version": "3.5.45",
3
+ "version": "3.6.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -36,18 +36,18 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@c88/v8-coverage": "0.1.1",
39
- "@jsenv/abort": "4.3.0",
40
- "@jsenv/ast": "6.5.2",
41
- "@jsenv/exception": "1.1.4",
42
- "@jsenv/filesystem": "4.13.5",
43
- "@jsenv/github-check-run": "0.2.12",
44
- "@jsenv/node-esm-resolution": "1.0.7",
45
- "@jsenv/humanize": "1.2.8",
46
- "@jsenv/plugin-supervisor": "1.6.6",
47
- "@jsenv/sourcemap": "1.2.30",
48
- "@jsenv/url-meta": "8.5.3",
49
- "@jsenv/urls": "2.6.0",
50
- "@jsenv/utils": "2.1.3",
39
+ "@jsenv/abort": "4.3.1",
40
+ "@jsenv/ast": "6.6.0",
41
+ "@jsenv/exception": "1.1.5",
42
+ "@jsenv/filesystem": "4.14.0",
43
+ "@jsenv/github-check-run": "0.2.14",
44
+ "@jsenv/node-esm-resolution": "1.1.0",
45
+ "@jsenv/humanize": "1.3.0",
46
+ "@jsenv/plugin-supervisor": "1.6.7",
47
+ "@jsenv/sourcemap": "1.3.0",
48
+ "@jsenv/url-meta": "8.5.4",
49
+ "@jsenv/urls": "2.6.1",
50
+ "@jsenv/utils": "2.2.0",
51
51
  "he": "1.2.0",
52
52
  "istanbul-lib-coverage": "3.2.2",
53
53
  "istanbul-lib-instrument": "6.0.3",
@@ -3,14 +3,23 @@ import { fileURLToPath } from "node:url";
3
3
 
4
4
  import { startServerUsingCommand } from "./start_using_command.js";
5
5
 
6
- export const startServerUsingModuleUrl = async (webServer, params) => {
6
+ export const startServerUsingModuleUrl = async (
7
+ webServer,
8
+ { ignoreProcessExecArgv, ...params },
9
+ ) => {
7
10
  if (!existsSync(new URL(webServer.moduleUrl))) {
8
11
  throw new Error(`"${webServer.moduleUrl}" does not lead to a file`);
9
12
  }
13
+ let command = `node`;
14
+ if (!ignoreProcessExecArgv && process.execArgv.length > 0) {
15
+ command += ` ${process.execArgv.join(" ")}`;
16
+ }
17
+ command += ` ${fileURLToPath(webServer.moduleUrl)}`;
18
+
10
19
  return startServerUsingCommand(
11
20
  {
12
21
  ...webServer,
13
- command: `node ${fileURLToPath(webServer.moduleUrl)}`,
22
+ command,
14
23
  args: ["--jsenv-test"],
15
24
  },
16
25
  params,
@@ -37,20 +37,20 @@ export const assertAndNormalizeWebServer = async (
37
37
  teardownCallbackSet,
38
38
  logger,
39
39
  });
40
- const { headers } = await basicFetch(webServer.origin, {
41
- method: "GET",
42
- rejectUnauthorized: false,
43
- headers: {
44
- "x-server-inspect": "1",
40
+ const serverJsonResponse = await basicFetch(
41
+ `${webServer.origin}/.internal/server.json`,
42
+ {
43
+ method: "GET",
44
+ rejectUnauthorized: false,
45
45
  },
46
- });
47
- if (String(headers["server"]).includes("jsenv_dev_server")) {
46
+ );
47
+ if (
48
+ serverJsonResponse.status === 200 &&
49
+ String(serverJsonResponse.headers["server"]).includes("jsenv_dev_server")
50
+ ) {
48
51
  webServer.isJsenvDevServer = true;
49
- const { json } = await basicFetch(`${webServer.origin}/__params__.json`, {
50
- rejectUnauthorized: false,
51
- });
52
52
  if (webServer.rootDirectoryUrl === undefined) {
53
- const jsenvDevServerParams = await json();
53
+ const jsenvDevServerParams = await serverJsonResponse.json();
54
54
  webServer.rootDirectoryUrl = jsenvDevServerParams.sourceDirectoryUrl;
55
55
  } else {
56
56
  webServer.rootDirectoryUrl = assertAndNormalizeDirectoryUrl(
@@ -68,7 +68,13 @@ export const assertAndNormalizeWebServer = async (
68
68
 
69
69
  export const ensureWebServerIsStarted = async (
70
70
  webServer,
71
- { signal, teardownCallbackSet, logger, allocatedMs = 5_000 },
71
+ {
72
+ signal,
73
+ teardownCallbackSet,
74
+ logger,
75
+ allocatedMs = 5_000,
76
+ ignoreProcessExecArgv,
77
+ },
72
78
  ) => {
73
79
  const aServerIsListening = await pingServer(webServer.origin);
74
80
  if (aServerIsListening) {
@@ -76,6 +82,7 @@ export const ensureWebServerIsStarted = async (
76
82
  }
77
83
  if (webServer.moduleUrl) {
78
84
  await startServerUsingModuleUrl(webServer, {
85
+ ignoreProcessExecArgv,
79
86
  signal,
80
87
  allocatedMs,
81
88
  teardownCallbackSet,
@@ -85,6 +92,7 @@ export const ensureWebServerIsStarted = async (
85
92
  }
86
93
  if (webServer.command) {
87
94
  await startServerUsingCommand(webServer, {
95
+ ignoreProcessExecArgv,
88
96
  signal,
89
97
  allocatedMs,
90
98
  teardownCallbackSet,
@@ -1,3 +0,0 @@
1
- import { register } from "node:module";
2
-
3
- register(new URL("./js/importmap_hooks.mjs", import.meta.url));