supertape 12.0.2 → 12.0.4

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/ChangeLog CHANGED
@@ -1,3 +1,14 @@
1
+ 2026.01.08, v12.0.4
2
+
3
+ feature:
4
+ - 047a98a supertape: cli: get rid of mock-require
5
+ - 1a4fc24 supertape: validator: get rid of mock-require
6
+
7
+ 2026.01.07, v12.0.3
8
+
9
+ feature:
10
+ - cd916cb cli: get rid of mock-require
11
+
1
12
  2026.01.07, v12.0.2
2
13
 
3
14
  feature:
@@ -6,51 +6,58 @@ const {isArray} = Array;
6
6
  const maybeFirst = (a) => isArray(a) ? a.pop() : a;
7
7
  const maybeArray = (a) => isArray(a) ? a : [a];
8
8
 
9
- const {
10
- SUPERTAPE_CHECK_DUPLICATES = '1',
11
- SUPERTAPE_CHECK_SCOPES = '1',
12
- SUPERTAPE_CHECK_ASSERTIONS_COUNT = '1',
13
- } = process.env;
14
-
15
- const yargsOptions = {
16
- configuration: {
17
- 'strip-aliased': true,
18
- 'strip-dashed': true,
19
- },
20
- coerce: {
21
- require: maybeArray,
22
- format: maybeFirst,
23
- },
24
- string: [
25
- 'format',
26
- 'require',
27
- ],
28
- boolean: [
29
- 'version',
30
- 'help',
31
- 'check-duplicates',
32
- 'check-scopes',
33
- 'check-assertions-count',
34
- 'worker',
35
- ],
36
- alias: {
37
- version: 'v',
38
- format: 'f',
39
- help: 'h',
40
- require: 'r',
41
- checkDuplicates: 'd',
42
- checkScopes: 's',
43
- checkAssertionsCount: 'a',
44
- },
45
- default: {
46
- format: 'progress-bar',
47
- require: [],
48
- checkDuplicates: SUPERTAPE_CHECK_DUPLICATES !== '0',
49
- checkScopes: SUPERTAPE_CHECK_SCOPES !== '0',
50
- checkAssertionsCount: SUPERTAPE_CHECK_ASSERTIONS_COUNT !== '0',
51
- worker: true,
52
- },
9
+ const getYargsOptions = () => {
10
+ const {
11
+ SUPERTAPE_CHECK_DUPLICATES = '1',
12
+ SUPERTAPE_CHECK_SCOPES = '1',
13
+ SUPERTAPE_CHECK_ASSERTIONS_COUNT = '1',
14
+ } = process.env;
15
+
16
+ const yargsOptions = {
17
+ configuration: {
18
+ 'strip-aliased': true,
19
+ 'strip-dashed': true,
20
+ },
21
+ coerce: {
22
+ require: maybeArray,
23
+ format: maybeFirst,
24
+ },
25
+ string: [
26
+ 'format',
27
+ 'require',
28
+ ],
29
+ boolean: [
30
+ 'version',
31
+ 'help',
32
+ 'check-duplicates',
33
+ 'check-scopes',
34
+ 'check-assertions-count',
35
+ 'worker',
36
+ ],
37
+ alias: {
38
+ version: 'v',
39
+ format: 'f',
40
+ help: 'h',
41
+ require: 'r',
42
+ checkDuplicates: 'd',
43
+ checkScopes: 's',
44
+ checkAssertionsCount: 'a',
45
+ },
46
+ default: {
47
+ format: 'progress-bar',
48
+ require: [],
49
+ checkDuplicates: SUPERTAPE_CHECK_DUPLICATES !== '0',
50
+ checkScopes: SUPERTAPE_CHECK_SCOPES !== '0',
51
+ checkAssertionsCount: SUPERTAPE_CHECK_ASSERTIONS_COUNT !== '0',
52
+ worker: true,
53
+ },
54
+ };
55
+
56
+ return yargsOptions;
53
57
  };
54
58
 
55
- module.exports.yargsOptions = yargsOptions;
56
- module.exports.parseArgs = (argv) => yargsParser(argv, yargsOptions);
59
+ module.exports.getYargsOptions = getYargsOptions;
60
+
61
+ module.exports.parseArgs = (argv) => {
62
+ return yargsParser(argv, getYargsOptions());
63
+ };
package/lib/cli.js CHANGED
@@ -1,19 +1,23 @@
1
1
  'use strict';
2
2
 
3
- const process = require('node:process');
4
3
  const {resolve: resolvePath} = require('node:path');
5
4
  const {once} = require('node:events');
6
5
  const {pathToFileURL} = require('node:url');
7
6
 
7
+ const {env} = require('node:process');
8
8
  const fullstore = require('fullstore');
9
9
  const {tryToCatch} = require('try-to-catch');
10
10
  const {keypress: _keypress} = require('@putout/cli-keypress');
11
11
 
12
12
  const {sync: _globSync} = require('glob');
13
13
 
14
- const {parseArgs, yargsOptions} = require('./cli/parse-args');
14
+ const {
15
+ parseArgs,
16
+ getYargsOptions,
17
+ } = require('./cli/parse-args');
15
18
 
16
19
  const _supertape = require('..');
20
+
17
21
  const {
18
22
  OK,
19
23
  FAIL,
@@ -23,14 +27,9 @@ const {
23
27
  SKIPPED,
24
28
  } = require('./exit-codes');
25
29
 
26
- const isExclude = (a) => !a.includes('node_modules');
27
- const removeDuplicates = (a) => Array.from(new Set(a));
28
-
29
30
  const filesCount = fullstore(0);
30
-
31
- const {
32
- SUPERTAPE_CHECK_SKIPPED = '0',
33
- } = process.env;
31
+ const removeDuplicates = (a) => Array.from(new Set(a));
32
+ const isExclude = (a) => !a.includes('node_modules');
34
33
 
35
34
  module.exports = async (overrides = {}) => {
36
35
  const {
@@ -45,9 +44,13 @@ module.exports = async (overrides = {}) => {
45
44
  globSync = _globSync,
46
45
  } = overrides;
47
46
 
47
+ const {
48
+ SUPERTAPE_CHECK_SKIPPED = '0',
49
+ } = env;
50
+
48
51
  const isStop = overrides.isStop || keypress().isStop;
49
52
 
50
- const [error, result] = await tryToCatch(cli, {
53
+ const [error, result] = await tryToCatch(_cli, {
51
54
  supertape,
52
55
  argv,
53
56
  cwd,
@@ -87,7 +90,7 @@ module.exports = async (overrides = {}) => {
87
90
  return exit(OK);
88
91
  };
89
92
 
90
- async function cli(overrides) {
93
+ async function _cli(overrides) {
91
94
  const {
92
95
  argv,
93
96
  cwd,
@@ -97,6 +100,7 @@ async function cli(overrides) {
97
100
  supertape,
98
101
  globSync,
99
102
  } = overrides;
103
+
100
104
  const args = parseArgs(argv);
101
105
 
102
106
  if (args.version) {
@@ -113,9 +117,11 @@ async function cli(overrides) {
113
117
 
114
118
  const {validateArgs} = await import('@putout/cli-validate-args');
115
119
 
120
+ const {boolean, string} = getYargsOptions();
121
+
116
122
  const error = await validateArgs(args, [
117
- ...yargsOptions.boolean,
118
- ...yargsOptions.string,
123
+ ...boolean,
124
+ ...string,
119
125
  ]);
120
126
 
121
127
  if (error)
@@ -159,6 +165,8 @@ async function cli(overrides) {
159
165
 
160
166
  const files = removeDuplicates(allFiles);
161
167
 
168
+ filesCount(files.length);
169
+
162
170
  if (!files.length)
163
171
  return OK;
164
172
 
@@ -169,8 +177,6 @@ async function cli(overrides) {
169
177
  resolvedNames.push(pathToFileURL(resolvePath(cwd, file)));
170
178
  }
171
179
 
172
- filesCount(files.length);
173
-
174
180
  for (const resolved of resolvedNames)
175
181
  await import(resolved);
176
182
 
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ const once = require('once');
4
+
5
+ module.exports.enableOnce = () => {
6
+ globalThis.onceDisabled = false;
7
+ };
8
+
9
+ module.exports.disableOnce = () => {
10
+ globalThis.onceDisabled = true;
11
+ };
12
+
13
+ module.exports.maybeOnce = (fn) => {
14
+ const onced = once(fn);
15
+
16
+ return (...a) => {
17
+ if (globalThis.onceDisabled)
18
+ return fn(...a);
19
+
20
+ return onced(...a);
21
+ };
22
+ };
package/lib/supertape.js CHANGED
@@ -5,7 +5,9 @@ const {EventEmitter} = require('node:events');
5
5
  const {PassThrough} = require('node:stream');
6
6
 
7
7
  const stub = require('@cloudcmd/stub');
8
+
8
9
  const once = require('once');
10
+ const {maybeOnce} = require('./maybe-once');
9
11
 
10
12
  const options = require('../supertape.json');
11
13
 
@@ -245,7 +247,7 @@ test.extend = (extensions) => {
245
247
  return extendedTest;
246
248
  };
247
249
 
248
- const loop = once(({emitter, tests}) => {
250
+ const loop = maybeOnce(({emitter, tests}) => {
249
251
  let previousCount = 0;
250
252
 
251
253
  (function loop() {
@@ -261,22 +263,6 @@ const loop = once(({emitter, tests}) => {
261
263
  });
262
264
 
263
265
  module.exports.run = () => {
264
- if (!mainEmitter)
265
- return fakeEmitter();
266
-
267
266
  mainEmitter.emit('loop');
268
-
269
267
  return mainEmitter;
270
268
  };
271
-
272
- function fakeEmitter() {
273
- const emitter = new EventEmitter();
274
-
275
- process.nextTick(() => {
276
- emitter.emit('end', {
277
- failed: 0,
278
- });
279
- });
280
-
281
- return emitter;
282
- }
package/lib/validator.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const once = require('once');
4
- const StackTracey = require('stacktracey');
4
+ const _StackTracey = require('stacktracey');
5
5
  const getDuplicatesMessage = ([, a]) => a;
6
6
 
7
7
  const getMessage = ({message, at, validations}) => [
@@ -71,11 +71,19 @@ module.exports.createValidator = ({tests}) => (msg, options) => {
71
71
  return [];
72
72
  };
73
73
 
74
- module.exports.getAt = () => getFileName();
75
-
76
74
  const CALLS_FROM_TEST = 3;
77
75
 
78
- function getFileName() {
76
+ module.exports.getAt = (overrides = {}) => {
77
+ const {
78
+ StackTracey = _StackTracey,
79
+ } = overrides;
80
+
81
+ return getFileName({
82
+ StackTracey,
83
+ });
84
+ };
85
+
86
+ function getFileName({StackTracey}) {
79
87
  const {items} = new StackTracey(Error());
80
88
 
81
89
  for (const {beforeParse, file} of items.slice(CALLS_FROM_TEST)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "supertape",
3
- "version": "12.0.2",
3
+ "version": "12.0.4",
4
4
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
5
5
  "description": "📼 Supertape simplest high speed test runner with superpowers",
6
6
  "homepage": "http://github.com/coderaiser/supertape",