@putout/operator-match-files 5.0.0 → 5.1.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/README.md +17 -0
- package/lib/match-files.js +16 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -101,6 +101,23 @@ module.exports = matchFiles({
|
|
|
101
101
|
});
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
+
### Exclude
|
|
105
|
+
|
|
106
|
+
If you want to exclude some files, use:
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
const {operator} = require('putout');
|
|
110
|
+
const {matchFiles} = operator;
|
|
111
|
+
const updateTSConfig = require('../update-tsconfig');
|
|
112
|
+
|
|
113
|
+
module.exports = matchFiles({
|
|
114
|
+
files: {
|
|
115
|
+
'__name.ts -> __name.js': updateTSConfig,
|
|
116
|
+
},
|
|
117
|
+
exclude: ['*.d.ts'],
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
104
121
|
### Options
|
|
105
122
|
|
|
106
123
|
You can also pass `options`:
|
package/lib/match-files.js
CHANGED
|
@@ -25,9 +25,16 @@ const isObject = (a) => a && typeof a === 'object';
|
|
|
25
25
|
const {entries} = Object;
|
|
26
26
|
const report = (path, {message}) => message;
|
|
27
27
|
|
|
28
|
-
module.exports.matchFiles = (
|
|
28
|
+
module.exports.matchFiles = (options) => {
|
|
29
|
+
const files = options.files ?? options;
|
|
30
|
+
const exclude = options.exclude ?? [];
|
|
31
|
+
|
|
29
32
|
check(files);
|
|
30
|
-
|
|
33
|
+
|
|
34
|
+
const scan = createScan({
|
|
35
|
+
files,
|
|
36
|
+
exclude,
|
|
37
|
+
});
|
|
31
38
|
|
|
32
39
|
return {
|
|
33
40
|
fix,
|
|
@@ -53,18 +60,22 @@ function fix(inputFile, {dirPath, mainPath, matchInputFilename, outputFilename,
|
|
|
53
60
|
removeFile(inputFile);
|
|
54
61
|
}
|
|
55
62
|
|
|
56
|
-
const createScan = (files) => (mainPath, {push, progress, options}) => {
|
|
63
|
+
const createScan = ({files, exclude}) => (mainPath, {push, progress, options}) => {
|
|
57
64
|
const allFiles = [];
|
|
58
65
|
const cwd = getFilename(mainPath);
|
|
59
66
|
|
|
60
67
|
for (const [filename, rawOptions] of entries(files)) {
|
|
61
|
-
const [
|
|
62
|
-
const inputFiles = findFile(mainPath,
|
|
68
|
+
const [matchInputFilenameMask] = parseMatcher(filename, options);
|
|
69
|
+
const inputFiles = findFile(mainPath, matchInputFilenameMask, exclude);
|
|
63
70
|
|
|
64
71
|
for (const inputFile of inputFiles) {
|
|
65
72
|
const dirPath = getParentDirectory(inputFile);
|
|
66
73
|
const inputFilename = getFilename(inputFile);
|
|
67
74
|
|
|
75
|
+
const [matchInputFilename, outputFilename = matchInputFilename] = parseMatcher(filename, {
|
|
76
|
+
filename: inputFilename,
|
|
77
|
+
});
|
|
78
|
+
|
|
68
79
|
if (ignores(cwd, inputFilename, options))
|
|
69
80
|
continue;
|
|
70
81
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/operator-match-files",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout operator adds ability to match files to plugins",
|