@putout/test 5.9.0 → 5.11.0
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/eslint/eslint.mjs +36 -3
- package/lib/processor/index.js +2 -1
- package/package.json +2 -2
package/lib/eslint/eslint.mjs
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import {readFile} from 'fs/promises';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
readFileSync,
|
|
4
|
+
writeFileSync,
|
|
5
|
+
unlinkSync,
|
|
6
|
+
} from 'fs';
|
|
7
|
+
import {
|
|
8
|
+
join,
|
|
9
|
+
extname,
|
|
10
|
+
basename,
|
|
11
|
+
} from 'path';
|
|
4
12
|
|
|
5
13
|
import eslint from '@putout/eslint';
|
|
6
14
|
import tryToCatch from 'try-to-catch';
|
|
@@ -12,6 +20,21 @@ import tryCatch from 'try-catch';
|
|
|
12
20
|
const {keys} = Object;
|
|
13
21
|
const {isArray} = Array;
|
|
14
22
|
|
|
23
|
+
const isUpdate = () => process.env.UPDATE === '1';
|
|
24
|
+
const update = (name, data) => {
|
|
25
|
+
const fn = global.writeFileSync || writeFileSync;
|
|
26
|
+
fn(name, data);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const remove = (name) => {
|
|
30
|
+
const ext = extname(name);
|
|
31
|
+
const base = basename(name, ext);
|
|
32
|
+
const fixtureName = name.replace(base, `${base}-fix`);
|
|
33
|
+
|
|
34
|
+
const fn = global.unlinkSync || unlinkSync;
|
|
35
|
+
tryCatch(fn, String(fixtureName));
|
|
36
|
+
};
|
|
37
|
+
|
|
15
38
|
const getMessage = ({message}) => message;
|
|
16
39
|
const config = {
|
|
17
40
|
extends: [
|
|
@@ -46,7 +69,7 @@ export const createTest = (url, plugins = {}) => {
|
|
|
46
69
|
process: (operator) => async (name, override) => {
|
|
47
70
|
const full = join(fixtureDir, name);
|
|
48
71
|
const [resolvedName, code] = await read(full);
|
|
49
|
-
const [, fixture] = await read(`${full}-fix`);
|
|
72
|
+
const [fixturePath, fixture] = await read(`${full}-fix`);
|
|
50
73
|
const fix = true;
|
|
51
74
|
|
|
52
75
|
const [source] = await eslint({
|
|
@@ -60,6 +83,11 @@ export const createTest = (url, plugins = {}) => {
|
|
|
60
83
|
},
|
|
61
84
|
});
|
|
62
85
|
|
|
86
|
+
if (isUpdate()) {
|
|
87
|
+
update(fixturePath, source);
|
|
88
|
+
return operator.pass('fixture updated');
|
|
89
|
+
}
|
|
90
|
+
|
|
63
91
|
return operator.equal(source, fixture);
|
|
64
92
|
},
|
|
65
93
|
noProcess: (operator) => async (name) => {
|
|
@@ -74,6 +102,11 @@ export const createTest = (url, plugins = {}) => {
|
|
|
74
102
|
fix,
|
|
75
103
|
});
|
|
76
104
|
|
|
105
|
+
if (isUpdate()) {
|
|
106
|
+
remove(resolvedName);
|
|
107
|
+
return operator.pass('fixture updated');
|
|
108
|
+
}
|
|
109
|
+
|
|
77
110
|
return operator.equal(source, code);
|
|
78
111
|
},
|
|
79
112
|
comparePlaces: (operator) => async (name, expected, override) => {
|
package/lib/processor/index.js
CHANGED
|
@@ -93,7 +93,7 @@ const createComparePlaces = (dir, options) => (operator) => async (filename, exp
|
|
|
93
93
|
};
|
|
94
94
|
module.exports._createComparePlaces = createComparePlaces;
|
|
95
95
|
|
|
96
|
-
async function process(filename, dir, {processors, plugins, extension, fix = true, noChange = false}) {
|
|
96
|
+
async function process(filename, dir, {processors, plugins, extension, fix = true, noChange = false, processorRunners}) {
|
|
97
97
|
extension = addDot(extname(filename).slice(1) || extension);
|
|
98
98
|
filename = basename(filename, String(extension));
|
|
99
99
|
|
|
@@ -117,6 +117,7 @@ async function process(filename, dir, {processors, plugins, extension, fix = tru
|
|
|
117
117
|
processFile: processFile({fix}),
|
|
118
118
|
options,
|
|
119
119
|
rawSource,
|
|
120
|
+
processorRunners,
|
|
120
121
|
});
|
|
121
122
|
|
|
122
123
|
if (isUpdate() && !noChange)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/test",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.11.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Test runner for 🐊Putout plugins ",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"eslint": "^8.0.1",
|
|
68
68
|
"eslint-plugin-n": "^15.2.4",
|
|
69
69
|
"eslint-plugin-putout": "^16.0.0",
|
|
70
|
-
"lerna": "^
|
|
70
|
+
"lerna": "^6.0.1",
|
|
71
71
|
"madrun": "^9.0.0",
|
|
72
72
|
"mock-require": "^3.0.3",
|
|
73
73
|
"nodemon": "^2.0.1"
|