supertape 12.0.3 → 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,9 @@
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
+
1
7
  2026.01.07, v12.0.3
2
8
 
3
9
  feature:
package/lib/cli.js CHANGED
@@ -1,10 +1,10 @@
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');
@@ -17,6 +17,7 @@ const {
17
17
  } = require('./cli/parse-args');
18
18
 
19
19
  const _supertape = require('..');
20
+
20
21
  const {
21
22
  OK,
22
23
  FAIL,
@@ -26,14 +27,9 @@ const {
26
27
  SKIPPED,
27
28
  } = require('./exit-codes');
28
29
 
29
- const isExclude = (a) => !a.includes('node_modules');
30
- const removeDuplicates = (a) => Array.from(new Set(a));
31
-
32
30
  const filesCount = fullstore(0);
33
-
34
- const {
35
- SUPERTAPE_CHECK_SKIPPED = '0',
36
- } = process.env;
31
+ const removeDuplicates = (a) => Array.from(new Set(a));
32
+ const isExclude = (a) => !a.includes('node_modules');
37
33
 
38
34
  module.exports = async (overrides = {}) => {
39
35
  const {
@@ -48,6 +44,10 @@ module.exports = async (overrides = {}) => {
48
44
  globSync = _globSync,
49
45
  } = overrides;
50
46
 
47
+ const {
48
+ SUPERTAPE_CHECK_SKIPPED = '0',
49
+ } = env;
50
+
51
51
  const isStop = overrides.isStop || keypress().isStop;
52
52
 
53
53
  const [error, result] = await tryToCatch(_cli, {
@@ -165,6 +165,8 @@ async function _cli(overrides) {
165
165
 
166
166
  const files = removeDuplicates(allFiles);
167
167
 
168
+ filesCount(files.length);
169
+
168
170
  if (!files.length)
169
171
  return OK;
170
172
 
@@ -175,8 +177,6 @@ async function _cli(overrides) {
175
177
  resolvedNames.push(pathToFileURL(resolvePath(cwd, file)));
176
178
  }
177
179
 
178
- filesCount(files.length);
179
-
180
180
  for (const resolved of resolvedNames)
181
181
  await import(resolved);
182
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.3",
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",