@putout/test 15.5.0 → 15.5.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.
package/README.md CHANGED
@@ -21,7 +21,7 @@ Set environment variable `UPDATE=1` to update `transform` and `format` fixtures
21
21
  UPDATE=1 tape test/*.js
22
22
  ```
23
23
 
24
- When you need to overide extension use `UPDATE_EXTENSION`, for example `UPDATE_EXTENSION=abc` will create files with extension 'abc'.
24
+ When you need to override extension use `UPDATE_EXTENSION`, for example `UPDATE_EXTENSION=abc` will create files with extension 'abc'.
25
25
 
26
26
  ## Plugins API
27
27
 
@@ -65,6 +65,7 @@ You can also pass extensions to read from `fixture` directory:
65
65
  ```js
66
66
  const test = createTest(import.meta.url, {
67
67
  extension: 'wast',
68
+ extensionFix: 'wast',
68
69
  lint: putout,
69
70
  plugins: [
70
71
  ['remove-unused-variables', rmVars],
package/lib/fixture.js CHANGED
@@ -1,13 +1,15 @@
1
1
  import process from 'node:process';
2
2
  import {tryCatch} from 'try-catch';
3
3
 
4
- const isUpdate = () => Boolean(Number(process.env.UPDATE));
4
+ const {env} = process;
5
+ const isUpdate = () => Boolean(Number(env.UPDATE));
6
+
5
7
  const TS = {
6
8
  ENABLED: true,
7
9
  DISABLED: false,
8
10
  };
9
11
 
10
- export const readFixture = (name, extension) => {
12
+ export const readFixture = (name, extension, extensionFix = env.UPDATE_EXTENSION) => {
11
13
  const {readFileSync} = globalThis.__putout_test_fs;
12
14
  const [eTS, dataTS] = tryCatch(readFileSync, `${name}.ts`, 'utf8');
13
15
 
@@ -28,14 +30,13 @@ export const readFixture = (name, extension) => {
28
30
  ];
29
31
 
30
32
  if (extension) {
31
- const {UPDATE_EXTENSION} = process.env;
32
33
  const [e, data] = tryCatch(readFileSync, `${name}.${extension}`, 'utf8');
33
34
 
34
35
  if (!e)
35
36
  return [
36
37
  data,
37
38
  TS.DISABLED,
38
- UPDATE_EXTENSION || extension,
39
+ extensionFix || extension,
39
40
  ];
40
41
  }
41
42
 
package/lib/test.js CHANGED
@@ -62,6 +62,7 @@ export function createTest(url, maybeOptions, maybeExtends = {}) {
62
62
  const dir = join(maybeDirectory(url), 'fixture');
63
63
  const {
64
64
  extension = '',
65
+ extensionFix,
65
66
  lint = putout,
66
67
  ...options
67
68
  } = parseOptions(maybeOptions);
@@ -71,6 +72,7 @@ export function createTest(url, maybeOptions, maybeExtends = {}) {
71
72
  const linterOptions = {
72
73
  lint,
73
74
  extension,
75
+ extensionFix,
74
76
  };
75
77
 
76
78
  preTest(test, plugin);
@@ -160,11 +162,16 @@ const progressWithOptions = (dir, options) => (t) => async (name, pluginOptions,
160
162
  };
161
163
 
162
164
  const transform = currify((dir, linterOptions, options, t, name, transformed = null, addons = {}) => {
163
- const {lint, extension} = linterOptions;
165
+ const {
166
+ lint,
167
+ extension,
168
+ extensionFix,
169
+ } = linterOptions;
170
+
164
171
  const {plugins} = options;
165
172
  const full = join(dir, name);
166
173
  const isStr = isString(transformed);
167
- const [input, isTS, currentExtension] = readFixture(full, extension);
174
+ const [input, isTS, currentExtension] = readFixture(full, extension, extensionFix);
168
175
 
169
176
  if (!isStr)
170
177
  addons = transformed;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/test",
3
- "version": "15.5.0",
3
+ "version": "15.5.1",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Test runner for 🐊Putout plugins ",