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