js-build-tools 3.0.0 → 3.0.2
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/dist/build.js +59 -59
- package/dist/bundle.js +12 -12
- package/dist/bundleLint.js +17 -17
- package/dist/bundleMinify.js +8 -8
- package/dist/copyFonts.js +8 -8
- package/dist/default.js +15 -15
- package/dist/distLint.js +17 -17
- package/dist/distMinify.js +8 -8
- package/dist/partials/addToReadme.js +13 -13
- package/dist/partials/beginWatcher.js +9 -9
- package/dist/partials/distFor.js +16 -16
- package/dist/partials/distForSrc.js +9 -9
- package/dist/partials/distSeries.js +19 -19
- package/dist/partials/imagesFor.js +27 -27
- package/dist/partials/readmeTemplate.js +11 -11
- package/dist/partials/runOnChange.js +27 -27
- package/dist/partials/sassFor.js +20 -20
- package/dist/partials/tsFor.js +20 -20
- package/dist/partials.js +34 -34
- package/dist/test-helpers/setUp.js +51 -51
- package/dist/testFull.js +17 -17
- package/dist/testHelpers.js +8 -8
- package/dist/testQuick.js +19 -19
- package/dist/utilities/dotGet.js +42 -42
- package/dist/utilities/dotNotate.js +50 -50
- package/dist/utilities/dotSet.js +36 -36
- package/dist/utilities/isObject.js +4 -4
- package/dist/utilities/strAfter.js +14 -0
- package/dist/utilities/strBefore.js +14 -0
- package/dist/watchTest.js +13 -13
- package/functions/utilities/dotGet.js +2 -2
- package/functions/utilities/dotSet.js +2 -2
- package/functions/utilities/strAfter.js +13 -0
- package/functions/utilities/strBefore.js +13 -0
- package/package.json +4 -4
- package/vendor/array-union/index.js +30 -30
- package/vendor/easy-transform-stream/index.js +54 -58
- package/vendor/globby/gitignore.js +96 -100
- package/vendor/globby/index.js +191 -195
- package/vendor/globby/stream-utils.js +57 -57
- package/vendor/globby/to-path.js +19 -19
- package/vendor/gulp-imagemin/index.js +5 -9
- package/vendor/gulp-plugin-extras/index.js +42 -46
- package/vendor/gulp-plugin-extras/plugin-error.js +144 -144
- package/vendor/ignore/index.js +467 -467
- package/vendor/imagemin/index.js +90 -94
- package/vendor/imagemin-gifsicle/index.js +33 -37
- package/vendor/imagemin-mozjpeg/index.js +100 -104
- package/vendor/imagemin-mozjpeg/node_modules/execa/index.js +2 -6
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/kill.js +2 -2
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stream.js +2 -6
- package/vendor/imagemin-optipng/index.js +43 -43
- package/vendor/imagemin-svgo/index.js +26 -26
- package/vendor/is-jpg/index.js +11 -11
- package/vendor/junk/index.js +48 -48
- package/vendor/mozjpeg/index.js +8 -8
- package/vendor/mozjpeg/lib/index.js +17 -17
- package/vendor/mozjpeg/package.json +49 -50
- package/vendor/mozjpeg/vendor/cjpeg +0 -0
- package/vendor/mozjpeg/vendor/source/mozjpeg.tar.gz +0 -0
- package/vendor/p-pipe/index.js +22 -26
- package/vendor/plur/index.js +31 -31
- package/vendor/pretty-bytes/index.js +70 -70
- package/vendor/slash/index.js +11 -11
|
@@ -1,100 +1,96 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
require("core-js/modules/esnext.async-iterator.
|
|
9
|
-
require("core-js/modules/esnext.
|
|
10
|
-
require("core-js/modules/esnext.iterator.
|
|
11
|
-
require("core-js/modules/esnext.iterator.
|
|
12
|
-
require("core-js/modules/
|
|
13
|
-
require("
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
exports.isGitIgnoredSync = isGitIgnoredSync;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
exportGlobby()
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isGitIgnoredSync = exports.isGitIgnored = void 0;
|
|
7
|
+
require("core-js/modules/esnext.async-iterator.filter.js");
|
|
8
|
+
require("core-js/modules/esnext.async-iterator.map.js");
|
|
9
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
10
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
11
|
+
require("core-js/modules/esnext.iterator.map.js");
|
|
12
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
13
|
+
var _nodeProcess = _interopRequireDefault(require("node:process"));
|
|
14
|
+
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
15
|
+
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
16
|
+
var _fastGlob = _interopRequireDefault(require("fast-glob"));
|
|
17
|
+
var _index = _interopRequireDefault(require("../ignore/index.js"));
|
|
18
|
+
var _index2 = _interopRequireDefault(require("./node_modules/slash/index.js"));
|
|
19
|
+
var _toPath = _interopRequireDefault(require("./to-path.js"));
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
const DEFAULT_IGNORE = ['**/node_modules/**', '**/flow-typed/**', '**/coverage/**', '**/.git'];
|
|
22
|
+
const mapGitIgnorePatternTo = base => ignore => {
|
|
23
|
+
if (ignore.startsWith('!')) {
|
|
24
|
+
return '!' + _nodePath.default.posix.join(base, ignore.slice(1));
|
|
25
|
+
}
|
|
26
|
+
return _nodePath.default.posix.join(base, ignore);
|
|
27
|
+
};
|
|
28
|
+
const parseGitIgnore = (content, options) => {
|
|
29
|
+
const base = (0, _index2.default)(_nodePath.default.relative(options.cwd, _nodePath.default.dirname(options.fileName)));
|
|
30
|
+
return content.split(/\r?\n/).filter(Boolean).filter(line => !line.startsWith('#')).map(mapGitIgnorePatternTo(base));
|
|
31
|
+
};
|
|
32
|
+
const reduceIgnore = files => {
|
|
33
|
+
const ignores = (0, _index.default)();
|
|
34
|
+
for (const file of files) {
|
|
35
|
+
ignores.add(parseGitIgnore(file.content, {
|
|
36
|
+
cwd: file.cwd,
|
|
37
|
+
fileName: file.filePath
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
return ignores;
|
|
41
|
+
};
|
|
42
|
+
const ensureAbsolutePathForCwd = (cwd, p) => {
|
|
43
|
+
cwd = (0, _index2.default)(cwd);
|
|
44
|
+
if (_nodePath.default.isAbsolute(p)) {
|
|
45
|
+
if ((0, _index2.default)(p).startsWith(cwd)) {
|
|
46
|
+
return p;
|
|
47
|
+
}
|
|
48
|
+
throw new Error("Path ".concat(p, " is not in cwd ").concat(cwd));
|
|
49
|
+
}
|
|
50
|
+
return _nodePath.default.join(cwd, p);
|
|
51
|
+
};
|
|
52
|
+
const getIsIgnoredPredicate = (ignores, cwd) => p => ignores.ignores((0, _index2.default)(_nodePath.default.relative(cwd, ensureAbsolutePathForCwd(cwd, (0, _toPath.default)(p.path || p)))));
|
|
53
|
+
const getFile = async (file, cwd) => {
|
|
54
|
+
const filePath = _nodePath.default.join(cwd, file);
|
|
55
|
+
const content = await _nodeFs.default.promises.readFile(filePath, 'utf8');
|
|
56
|
+
return {
|
|
57
|
+
cwd,
|
|
58
|
+
filePath,
|
|
59
|
+
content
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
const getFileSync = (file, cwd) => {
|
|
63
|
+
const filePath = _nodePath.default.join(cwd, file);
|
|
64
|
+
const content = _nodeFs.default.readFileSync(filePath, 'utf8');
|
|
65
|
+
return {
|
|
66
|
+
cwd,
|
|
67
|
+
filePath,
|
|
68
|
+
content
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
const normalizeOptions = function () {
|
|
72
|
+
let {
|
|
73
|
+
ignore = [],
|
|
74
|
+
cwd = (0, _index2.default)(_nodeProcess.default.cwd())
|
|
75
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
76
|
+
return {
|
|
77
|
+
ignore: [...DEFAULT_IGNORE, ...ignore],
|
|
78
|
+
cwd: (0, _toPath.default)(cwd)
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
const isGitIgnored = async options => {
|
|
82
|
+
options = normalizeOptions(options);
|
|
83
|
+
const paths = await (0, _fastGlob.default)('**/.gitignore', options);
|
|
84
|
+
const files = await Promise.all(paths.map(file => getFile(file, options.cwd)));
|
|
85
|
+
const ignores = reduceIgnore(files);
|
|
86
|
+
return getIsIgnoredPredicate(ignores, options.cwd);
|
|
87
|
+
};
|
|
88
|
+
exports.isGitIgnored = isGitIgnored;
|
|
89
|
+
const isGitIgnoredSync = options => {
|
|
90
|
+
options = normalizeOptions(options);
|
|
91
|
+
const paths = _fastGlob.default.sync('**/.gitignore', options);
|
|
92
|
+
const files = paths.map(file => getFileSync(file, options.cwd));
|
|
93
|
+
const ignores = reduceIgnore(files);
|
|
94
|
+
return getIsIgnoredPredicate(ignores, options.cwd);
|
|
95
|
+
};
|
|
96
|
+
exports.isGitIgnoredSync = isGitIgnoredSync;
|
package/vendor/globby/index.js
CHANGED
|
@@ -1,195 +1,191 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
require("core-js/modules/
|
|
21
|
-
require("core-js/modules/esnext.async-iterator.
|
|
22
|
-
require("core-js/modules/esnext.async-iterator.
|
|
23
|
-
require("core-js/modules/esnext.async-iterator.
|
|
24
|
-
require("core-js/modules/esnext.
|
|
25
|
-
require("core-js/modules/esnext.iterator.
|
|
26
|
-
require("core-js/modules/esnext.iterator.
|
|
27
|
-
require("core-js/modules/esnext.iterator.
|
|
28
|
-
require("core-js/modules/esnext.iterator.
|
|
29
|
-
require("core-js/modules/
|
|
30
|
-
require("
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
...taskOptions,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
...options
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const
|
|
157
|
-
const
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
const
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
exports.isDynamicPattern = isDynamicPattern;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
exportGlobby()
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isDynamicPattern = exports.globbySync = exports.globbyStream = exports.globby = exports.generateGlobTasks = void 0;
|
|
7
|
+
Object.defineProperty(exports, "isGitIgnored", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _gitignore.isGitIgnored;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "isGitIgnoredSync", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _gitignore.isGitIgnoredSync;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
require("core-js/modules/es.array.unscopables.flat.js");
|
|
20
|
+
require("core-js/modules/esnext.async-iterator.every.js");
|
|
21
|
+
require("core-js/modules/esnext.async-iterator.filter.js");
|
|
22
|
+
require("core-js/modules/esnext.async-iterator.map.js");
|
|
23
|
+
require("core-js/modules/esnext.async-iterator.some.js");
|
|
24
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
25
|
+
require("core-js/modules/esnext.iterator.every.js");
|
|
26
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
27
|
+
require("core-js/modules/esnext.iterator.map.js");
|
|
28
|
+
require("core-js/modules/esnext.iterator.some.js");
|
|
29
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
30
|
+
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
31
|
+
var _index = _interopRequireDefault(require("../array-union/index.js"));
|
|
32
|
+
var _merge = _interopRequireDefault(require("merge2"));
|
|
33
|
+
var _fastGlob = _interopRequireDefault(require("fast-glob"));
|
|
34
|
+
var _dirGlob = _interopRequireDefault(require("dir-glob"));
|
|
35
|
+
var _toPath = _interopRequireDefault(require("./to-path.js"));
|
|
36
|
+
var _gitignore = require("./gitignore.js");
|
|
37
|
+
var _streamUtils = require("./stream-utils.js");
|
|
38
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
|
+
const DEFAULT_FILTER = () => false;
|
|
40
|
+
const isNegative = pattern => pattern[0] === '!';
|
|
41
|
+
const assertPatternsInput = patterns => {
|
|
42
|
+
if (!patterns.every(pattern => typeof pattern === 'string')) {
|
|
43
|
+
throw new TypeError('Patterns must be a string or an array of strings');
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const checkCwdOption = options => {
|
|
47
|
+
if (!options.cwd) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
let stat;
|
|
51
|
+
try {
|
|
52
|
+
stat = _nodeFs.default.statSync(options.cwd);
|
|
53
|
+
} catch {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (!stat.isDirectory()) {
|
|
57
|
+
throw new Error('The `cwd` option must be a path to a directory');
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const getPathString = p => p.stats instanceof _nodeFs.default.Stats ? p.path : p;
|
|
61
|
+
const generateGlobTasks = function (patterns) {
|
|
62
|
+
let taskOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
63
|
+
patterns = (0, _index.default)([patterns].flat());
|
|
64
|
+
assertPatternsInput(patterns);
|
|
65
|
+
const globTasks = [];
|
|
66
|
+
taskOptions = {
|
|
67
|
+
ignore: [],
|
|
68
|
+
expandDirectories: true,
|
|
69
|
+
...taskOptions,
|
|
70
|
+
cwd: (0, _toPath.default)(taskOptions.cwd)
|
|
71
|
+
};
|
|
72
|
+
checkCwdOption(taskOptions);
|
|
73
|
+
for (const [index, pattern] of patterns.entries()) {
|
|
74
|
+
if (isNegative(pattern)) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const ignore = patterns.slice(index).filter(pattern => isNegative(pattern)).map(pattern => pattern.slice(1));
|
|
78
|
+
const options = {
|
|
79
|
+
...taskOptions,
|
|
80
|
+
ignore: [...taskOptions.ignore, ...ignore]
|
|
81
|
+
};
|
|
82
|
+
globTasks.push({
|
|
83
|
+
pattern,
|
|
84
|
+
options
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return globTasks;
|
|
88
|
+
};
|
|
89
|
+
exports.generateGlobTasks = generateGlobTasks;
|
|
90
|
+
const globDirectories = (task, fn) => {
|
|
91
|
+
let options = {};
|
|
92
|
+
if (task.options.cwd) {
|
|
93
|
+
options.cwd = task.options.cwd;
|
|
94
|
+
}
|
|
95
|
+
if (Array.isArray(task.options.expandDirectories)) {
|
|
96
|
+
options = {
|
|
97
|
+
...options,
|
|
98
|
+
files: task.options.expandDirectories
|
|
99
|
+
};
|
|
100
|
+
} else if (typeof task.options.expandDirectories === 'object') {
|
|
101
|
+
options = {
|
|
102
|
+
...options,
|
|
103
|
+
...task.options.expandDirectories
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return fn(task.pattern, options);
|
|
107
|
+
};
|
|
108
|
+
const getPattern = (task, fn) => task.options.expandDirectories ? globDirectories(task, fn) : [task.pattern];
|
|
109
|
+
const getFilterSync = options => options && options.gitignore ? (0, _gitignore.isGitIgnoredSync)({
|
|
110
|
+
cwd: options.cwd,
|
|
111
|
+
ignore: options.ignore
|
|
112
|
+
}) : DEFAULT_FILTER;
|
|
113
|
+
const globToTask = task => async glob => {
|
|
114
|
+
const {
|
|
115
|
+
options
|
|
116
|
+
} = task;
|
|
117
|
+
if (options.ignore && Array.isArray(options.ignore) && options.expandDirectories) {
|
|
118
|
+
options.ignore = await (0, _dirGlob.default)(options.ignore);
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
pattern: glob,
|
|
122
|
+
options
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
const globToTaskSync = task => glob => {
|
|
126
|
+
const {
|
|
127
|
+
options
|
|
128
|
+
} = task;
|
|
129
|
+
if (options.ignore && Array.isArray(options.ignore) && options.expandDirectories) {
|
|
130
|
+
options.ignore = _dirGlob.default.sync(options.ignore);
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
pattern: glob,
|
|
134
|
+
options
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
const globby = async (patterns, options) => {
|
|
138
|
+
const globTasks = generateGlobTasks(patterns, options);
|
|
139
|
+
const getFilter = async () => options && options.gitignore ? (0, _gitignore.isGitIgnored)({
|
|
140
|
+
cwd: options.cwd,
|
|
141
|
+
ignore: options.ignore
|
|
142
|
+
}) : DEFAULT_FILTER;
|
|
143
|
+
const getTasks = async () => {
|
|
144
|
+
const tasks = await Promise.all(globTasks.map(async task => {
|
|
145
|
+
const globs = await getPattern(task, _dirGlob.default);
|
|
146
|
+
return Promise.all(globs.map(globToTask(task)));
|
|
147
|
+
}));
|
|
148
|
+
return (0, _index.default)(...tasks);
|
|
149
|
+
};
|
|
150
|
+
const [filter, tasks] = await Promise.all([getFilter(), getTasks()]);
|
|
151
|
+
const paths = await Promise.all(tasks.map(task => (0, _fastGlob.default)(task.pattern, task.options)));
|
|
152
|
+
return (0, _index.default)(...paths).filter(path_ => !filter(getPathString(path_)));
|
|
153
|
+
};
|
|
154
|
+
exports.globby = globby;
|
|
155
|
+
const globbySync = (patterns, options) => {
|
|
156
|
+
const globTasks = generateGlobTasks(patterns, options);
|
|
157
|
+
const tasks = [];
|
|
158
|
+
for (const task of globTasks) {
|
|
159
|
+
const newTask = getPattern(task, _dirGlob.default.sync).map(globToTaskSync(task));
|
|
160
|
+
tasks.push(...newTask);
|
|
161
|
+
}
|
|
162
|
+
const filter = getFilterSync(options);
|
|
163
|
+
let matches = [];
|
|
164
|
+
for (const task of tasks) {
|
|
165
|
+
matches = (0, _index.default)(matches, _fastGlob.default.sync(task.pattern, task.options));
|
|
166
|
+
}
|
|
167
|
+
return matches.filter(path_ => !filter(path_));
|
|
168
|
+
};
|
|
169
|
+
exports.globbySync = globbySync;
|
|
170
|
+
const globbyStream = (patterns, options) => {
|
|
171
|
+
const globTasks = generateGlobTasks(patterns, options);
|
|
172
|
+
const tasks = [];
|
|
173
|
+
for (const task of globTasks) {
|
|
174
|
+
const newTask = getPattern(task, _dirGlob.default.sync).map(globToTaskSync(task));
|
|
175
|
+
tasks.push(...newTask);
|
|
176
|
+
}
|
|
177
|
+
const filter = getFilterSync(options);
|
|
178
|
+
const filterStream = new _streamUtils.FilterStream(p => !filter(p));
|
|
179
|
+
const uniqueStream = new _streamUtils.UniqueStream();
|
|
180
|
+
return (0, _merge.default)(tasks.map(task => _fastGlob.default.stream(task.pattern, task.options))).pipe(filterStream).pipe(uniqueStream);
|
|
181
|
+
};
|
|
182
|
+
exports.globbyStream = globbyStream;
|
|
183
|
+
const isDynamicPattern = function (patterns) {
|
|
184
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
185
|
+
options = {
|
|
186
|
+
...options,
|
|
187
|
+
cwd: (0, _toPath.default)(options.cwd)
|
|
188
|
+
};
|
|
189
|
+
return [patterns].flat().some(pattern => _fastGlob.default.isDynamicPattern(pattern, options));
|
|
190
|
+
};
|
|
191
|
+
exports.isDynamicPattern = isDynamicPattern;
|