@putout/operator-match-files 5.2.0 → 5.3.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 +18 -1
- package/lib/match-files.js +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -101,7 +101,7 @@ module.exports = matchFiles({
|
|
|
101
101
|
});
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
###
|
|
104
|
+
### `exclude`
|
|
105
105
|
|
|
106
106
|
If you want to exclude some files, use:
|
|
107
107
|
|
|
@@ -138,6 +138,23 @@ module.exports = matchFiles({
|
|
|
138
138
|
});
|
|
139
139
|
```
|
|
140
140
|
|
|
141
|
+
### `filename`
|
|
142
|
+
|
|
143
|
+
You can pass default `filename`, so when no options provided it will be used.
|
|
144
|
+
|
|
145
|
+
```js
|
|
146
|
+
const {operator} = require('putout');
|
|
147
|
+
const {matchFiles} = operator;
|
|
148
|
+
const updateTSConfig = require('../update-tsconfig');
|
|
149
|
+
|
|
150
|
+
module.exports = matchFiles({
|
|
151
|
+
filename: '*.d.ts',
|
|
152
|
+
files: {
|
|
153
|
+
'__name.ts -> __name.js': updateTSConfig,
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
```
|
|
157
|
+
|
|
141
158
|
## License
|
|
142
159
|
|
|
143
160
|
MIT
|
package/lib/match-files.js
CHANGED
|
@@ -26,12 +26,14 @@ const {entries} = Object;
|
|
|
26
26
|
const report = (path, {message}) => message;
|
|
27
27
|
|
|
28
28
|
module.exports.matchFiles = (options) => {
|
|
29
|
+
const {filename} = options;
|
|
29
30
|
const files = options.files ?? options;
|
|
30
31
|
const exclude = options.exclude ?? [];
|
|
31
32
|
|
|
32
33
|
check(files);
|
|
33
34
|
|
|
34
35
|
const scan = createScan({
|
|
36
|
+
defaultFilename: filename,
|
|
35
37
|
files,
|
|
36
38
|
exclude,
|
|
37
39
|
});
|
|
@@ -60,10 +62,12 @@ function fix(inputFile, {dirPath, matchInputFilename, outputFilename, matchedJS,
|
|
|
60
62
|
removeFile(inputFile);
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
const createScan = ({files, exclude}) => (mainPath, {push, progress, options}) => {
|
|
65
|
+
const createScan = ({files, exclude, defaultFilename}) => (mainPath, {push, progress, options}) => {
|
|
64
66
|
const allFiles = [];
|
|
65
67
|
const cwd = getFilename(mainPath);
|
|
66
68
|
|
|
69
|
+
options.filename = options.filename ?? defaultFilename;
|
|
70
|
+
|
|
67
71
|
for (const [filename, rawOptions] of entries(files)) {
|
|
68
72
|
const [matchInputFilenameMask] = parseMatcher(filename, options);
|
|
69
73
|
const inputFiles = findFile(mainPath, matchInputFilenameMask, exclude);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/operator-match-files",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.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",
|