@brillout/test-e2e 0.5.31 → 0.5.32

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,7 +1,7 @@
1
1
  export { runCommandLongRunning };
2
- import { spawn as spawn_ } from 'child_process';
2
+ import { spawn } from 'child_process';
3
3
  import stripAnsi from 'strip-ansi';
4
- import { assert, runCommandShortLived, humanizeTime, isWindows, isLinux, isCallable, hasProp } from '../utils.js';
4
+ import { assert, runCommandShortLived, humanizeTime, isWindows, isLinux, isCallable } from '../utils.js';
5
5
  function runCommandLongRunning({ cmd, cwd, killPort, isReadyLog, isReadyTimeout, onStdout, onStderr, onExit, onTerminationError, terminationTimeout, }) {
6
6
  if (killPort)
7
7
  killByPort(killPort);
@@ -43,7 +43,7 @@ function runCommandLongRunning({ cmd, cwd, killPort, isReadyLog, isReadyTimeout,
43
43
  command = command + '.cmd';
44
44
  }
45
45
  }
46
- const proc = spawn(command, args, { cwd, detached });
46
+ const proc = spawn(command, args, { cwd, detached, ...nodeWorkaround });
47
47
  let procExited = false;
48
48
  proc.stdin.on('data', async (chunk) => {
49
49
  const data = String(chunk);
@@ -191,6 +191,7 @@ function stopProcess({ proc, cwd, cmd, force, onTerminationError, }) {
191
191
  // Ignoring stderr doesn't solve the problem that taskkill makes the process exit with code 1
192
192
  'inherit', // stderr
193
193
  ],
194
+ ...nodeWorkaround(),
194
195
  });
195
196
  }
196
197
  else {
@@ -228,13 +229,14 @@ function isSuccessCode(code) {
228
229
  const spawn2: typeof spawn_ = (...args) => spawn_(...args)
229
230
  const spawn3: typeof spawn_ = function(...args) { return spawn_(...args) }
230
231
  //*/
231
- function spawn(command, args, options) {
232
- // Workaround for Node.js regression:
233
- // - https://github.com/nodejs/node/issues/52475
234
- // - https://github.com/prebuild/prebuildify/issues/83#issuecomment-2056607495
235
- if (isWindows())
236
- options.shell = true;
237
- // Needed for spawn_() to return ChildProcessWithoutNullStreams instead of ChildProcess
238
- assert(hasProp(options, 'stdio', 'undefined'));
239
- return spawn_(command, args, options);
232
+ function nodeWorkaround() {
233
+ if (isWindows()) {
234
+ // Workaround for Node.js regression:
235
+ // - https://github.com/nodejs/node/issues/52475
236
+ // - https://github.com/prebuild/prebuildify/issues/83#issuecomment-2056607495
237
+ return { shell: true };
238
+ }
239
+ else {
240
+ return {};
241
+ }
240
242
  }
package/dist/utils.d.ts CHANGED
@@ -13,4 +13,3 @@ export * from './utils/isObject.js';
13
13
  export * from './utils/isCallable.js';
14
14
  export * from './utils/platform.js';
15
15
  export * from './utils/isMinNodeVersion.js';
16
- export * from './utils/hasProp.js';
package/dist/utils.js CHANGED
@@ -13,4 +13,3 @@ export * from './utils/isObject.js';
13
13
  export * from './utils/isCallable.js';
14
14
  export * from './utils/platform.js';
15
15
  export * from './utils/isMinNodeVersion.js';
16
- export * from './utils/hasProp.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/test-e2e",
3
- "version": "0.5.31",
3
+ "version": "0.5.32",
4
4
  "bin": "./bin.js",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",
@@ -1,15 +0,0 @@
1
- export { hasProp };
2
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'boolean'): obj is ObjectType & Record<PropName, boolean>;
3
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'number'): obj is ObjectType & Record<PropName, number>;
4
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'string'): obj is ObjectType & Record<PropName, string>;
5
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'object'): obj is ObjectType & Record<PropName, Record<string, unknown>>;
6
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'array'): obj is ObjectType & Record<PropName, unknown[]>;
7
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'string[]'): obj is ObjectType & Record<PropName, string[]>;
8
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'string{}'): obj is ObjectType & Record<PropName, Record<string, string>>;
9
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'function'): obj is ObjectType & Record<PropName, (...args: any[]) => unknown>;
10
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'undefined'): obj is ObjectType & Record<PropName, undefined>;
11
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'null'): obj is ObjectType & Record<PropName, null>;
12
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'true'): obj is ObjectType & Record<PropName, true>;
13
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName, type: 'false'): obj is ObjectType & Record<PropName, false>;
14
- declare function hasProp<ObjectType, PropName extends PropertyKey, Enum>(obj: ObjectType, prop: PropName, type: Enum[]): obj is ObjectType & Record<PropName, Enum>;
15
- declare function hasProp<ObjectType, PropName extends PropertyKey>(obj: ObjectType, prop: PropName): obj is ObjectType & Record<PropName, unknown>;
@@ -1,50 +0,0 @@
1
- export { hasProp };
2
- // - https://2ality.com/2020/06/type-guards-assertion-functions-typescript.html
3
- // - https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABDAzgFQJ4AcCmdgAUAbgIYA2IOAXIiWBgDSJTbWIDkARnHGTnewCUNUhRzIUibr35gA3AFgAUKEiwEEzLnzFylGnUbNWNdmBABbTjgBOQkXvGpE5q7cUrw0eElRa8hKL6tPRMLLimKFA2MGAA5vaIQU6SUTHxHqreGn6sOskGocYRHOAA1mBwAO5gickSiOWVNZle6r7oeYGOhUbhbGmxcYgAvKVgFdW1wlI8fHSIAN7KiMiExeIjW+OTNeyIgksrq4g2OFAgNkjRlMcAvsdnF1cb+EmOo9v9Hg9KyhAIKK0GhNKajRAAFgATMplCQUChbFACLltIQSEwzJZrHZBIJ-oCZAA6MhwOIEEj4v6eNQ+WgIpEEAFgAAmMHaIImzTAM3hiJsUEkzLZ7SOShOa0QTIQIp8hyelzAx1WUAAFjZqi4cFVEABRGwamwEdgAQQZArpADESDAyEJlHcgA
4
- import { isCallable } from './isCallable.js';
5
- import { isObject } from './isObject.js';
6
- import { isArrayOfStrings } from './isArrayOfStrings.js';
7
- import { isObjectOfStrings } from './isObjectOfStrings.js';
8
- import { isArray } from './isArray.js';
9
- function hasProp(obj, prop, type = 'unknown') {
10
- if (!isObject(obj))
11
- return false;
12
- if (!(prop in obj)) {
13
- return type === 'undefined';
14
- }
15
- if (type === 'unknown') {
16
- return true;
17
- }
18
- const propValue = obj[prop];
19
- if (type === 'array') {
20
- return isArray(propValue);
21
- }
22
- if (type === 'object') {
23
- return isObject(propValue);
24
- }
25
- if (type === 'string[]') {
26
- return isArrayOfStrings(propValue);
27
- }
28
- if (type === 'string{}') {
29
- return isObjectOfStrings(propValue);
30
- }
31
- if (type === 'function') {
32
- return isCallable(propValue);
33
- }
34
- if (isArray(type)) {
35
- return typeof propValue === 'string' && type.includes(propValue);
36
- }
37
- if (type === 'null') {
38
- return propValue === null;
39
- }
40
- if (type === 'undefined') {
41
- return propValue === undefined;
42
- }
43
- if (type === 'true') {
44
- return propValue === true;
45
- }
46
- if (type === 'false') {
47
- return propValue === false;
48
- }
49
- return typeof propValue === type;
50
- }
@@ -1 +0,0 @@
1
- export declare function isArray(value: unknown): value is unknown[];
@@ -1,4 +0,0 @@
1
- // Typesafe Array.isArray() — asserting unknown[] instead of any[]
2
- export function isArray(value) {
3
- return Array.isArray(value);
4
- }
@@ -1,2 +0,0 @@
1
- export { isArrayOfStrings };
2
- declare function isArrayOfStrings(val: unknown): val is string[];
@@ -1,5 +0,0 @@
1
- export { isArrayOfStrings };
2
- import { isArray } from './isArray.js';
3
- function isArrayOfStrings(val) {
4
- return isArray(val) && val.every((v) => typeof v === 'string');
5
- }
@@ -1,2 +0,0 @@
1
- export { isObjectOfStrings };
2
- declare function isObjectOfStrings(val: unknown): val is Record<string, string>;
@@ -1,5 +0,0 @@
1
- export { isObjectOfStrings };
2
- import { isObject } from './isObject.js';
3
- function isObjectOfStrings(val) {
4
- return isObject(val) && Object.values(val).every((v) => typeof v === 'string');
5
- }