@putout/test 13.2.1 → 13.2.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.
package/lib/fixture.js CHANGED
@@ -17,6 +17,7 @@ module.exports.readFixture = (name, extension) => {
17
17
  return [
18
18
  dataTS,
19
19
  TS.ENABLED,
20
+ 'ts',
20
21
  ];
21
22
 
22
23
  const [eJS, dataJS] = tryCatch(readFileSync, `${name}.js`, 'utf8');
@@ -25,6 +26,7 @@ module.exports.readFixture = (name, extension) => {
25
26
  return [
26
27
  dataJS,
27
28
  TS.DISABLED,
29
+ 'js',
28
30
  ];
29
31
 
30
32
  if (extension) {
@@ -34,18 +36,24 @@ module.exports.readFixture = (name, extension) => {
34
36
  return [
35
37
  data,
36
38
  TS.DISABLED,
39
+ extension,
37
40
  ];
38
41
  }
39
42
 
40
43
  throw eJS;
41
44
  };
42
45
 
43
- module.exports.writeFixture = ({full, code, extension}) => {
46
+ module.exports.writeFixFixture = ({full, code, extension}) => {
44
47
  const {writeFileSync} = global.__putout_test_fs;
45
48
  writeFileSync(`${full}-fix.${extension}`, code);
46
49
  };
47
50
 
48
- module.exports.rmFixture = (name) => {
51
+ module.exports.writeFixture = ({full, code, extension}) => {
52
+ const {writeFileSync} = global.__putout_test_fs;
53
+ writeFileSync(`${full}.${extension}`, code);
54
+ };
55
+
56
+ module.exports.rmFixture = (name, extension) => {
49
57
  const {unlinkSync} = global.__putout_test_fs;
50
58
 
51
59
  if (!isUpdate())
@@ -53,4 +61,5 @@ module.exports.rmFixture = (name) => {
53
61
 
54
62
  tryCatch(unlinkSync, `${name}.js`);
55
63
  tryCatch(unlinkSync, `${name}.ts`);
64
+ tryCatch(unlinkSync, `${name}.${extension}`);
56
65
  };
package/lib/test.js CHANGED
@@ -22,6 +22,7 @@ const {preTest} = require('./pre-test');
22
22
  const {
23
23
  readFixture,
24
24
  writeFixture,
25
+ writeFixFixture,
25
26
  rmFixture,
26
27
  } = require('./fixture');
27
28
 
@@ -300,7 +301,7 @@ const transform = currify((dir, linterOptions, options, t, name, transformed = n
300
301
  const {plugins} = options;
301
302
  const full = join(dir, name);
302
303
  const isStr = isString(transformed);
303
- const [input, isTS] = readFixture(full, extension);
304
+ const [input, isTS, currentExtension] = readFixture(full, extension);
304
305
 
305
306
  if (!isStr)
306
307
  addons = transformed;
@@ -320,10 +321,10 @@ const transform = currify((dir, linterOptions, options, t, name, transformed = n
320
321
  return fail(t, `'input' === 'output', use 'noTransform()'`);
321
322
 
322
323
  if (isUpdate() && !isStr) {
323
- writeFixture({
324
+ writeFixFixture({
324
325
  full,
325
326
  code,
326
- extension,
327
+ extension: currentExtension,
327
328
  });
328
329
  return t.pass('fixed fixture updated');
329
330
  }
@@ -337,7 +338,7 @@ const transformWithOptions = currify((dir, linterOptions, options, t, name, plug
337
338
  const {lint, extension} = linterOptions;
338
339
 
339
340
  const full = join(dir, name);
340
- const [input, isTS] = readFixture(full, extension);
341
+ const [input, isTS, currentExtension] = readFixture(full, extension);
341
342
 
342
343
  const rule = parseRule(options);
343
344
 
@@ -352,10 +353,10 @@ const transformWithOptions = currify((dir, linterOptions, options, t, name, plug
352
353
  });
353
354
 
354
355
  if (isUpdate()) {
355
- writeFixture({
356
+ writeFixFixture({
356
357
  full,
357
358
  code,
358
- extension,
359
+ extension: currentExtension,
359
360
  });
360
361
  return t.pass('fixed fixture updated');
361
362
  }
@@ -374,7 +375,7 @@ const parseRule = ({plugins}) => {
374
375
  const noTransformWithOptions = currify((dir, linterOptions, options, t, name, ruleOptions) => {
375
376
  const {lint, extension} = linterOptions;
376
377
  const full = join(dir, name);
377
- const [input, isTS] = readFixture(full, extension);
378
+ const [input, isTS, currentExtension] = readFixture(full, extension);
378
379
 
379
380
  rmFixture(`${full}-fix`);
380
381
 
@@ -393,7 +394,7 @@ const noTransformWithOptions = currify((dir, linterOptions, options, t, name, ru
393
394
  writeFixture({
394
395
  full,
395
396
  code,
396
- extension,
397
+ extension: currentExtension,
397
398
  });
398
399
 
399
400
  return t.pass('source fixture updated');
@@ -410,7 +411,7 @@ const noTransform = currify((dir, linterOptions, options, t, name, addons = {})
410
411
  rmFixture(`${full}-fix`);
411
412
 
412
413
  const {plugins} = options;
413
- const [input, isTS] = readFixture(full, extension);
414
+ const [input, isTS, currentExtension] = readFixture(full, extension);
414
415
 
415
416
  const {code} = lint(input, {
416
417
  isTS,
@@ -425,7 +426,7 @@ const noTransform = currify((dir, linterOptions, options, t, name, addons = {})
425
426
  writeFixture({
426
427
  full,
427
428
  code,
428
- extension,
429
+ extension: currentExtension,
429
430
  });
430
431
 
431
432
  return t.pass('source fixture updated');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/test",
3
- "version": "13.2.1",
3
+ "version": "13.2.3",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Test runner for 🐊Putout plugins ",
@@ -66,7 +66,7 @@
66
66
  "@putout/plugin-putout": "*",
67
67
  "@putout/plugin-remove-console": "*",
68
68
  "@putout/plugin-remove-unused-variables": "*",
69
- "@putout/processor-wasm": "^3.0.0",
69
+ "@putout/processor-wasm": "*",
70
70
  "c8": "^10.0.0",
71
71
  "eslint": "^9.0.0",
72
72
  "eslint-plugin-n": "^17.0.0",