aboutsummaryrefslogtreecommitdiff
path: root/node_modules/fast-glob/out/managers/tasks.js
diff options
context:
space:
mode:
authorDimitri Staessens <[email protected]>2019-10-06 21:37:45 +0200
committerDimitri Staessens <[email protected]>2019-10-06 21:37:45 +0200
commit3c51c3be85bb0d1bdb87ea0d6632f1c256912f27 (patch)
treec7ccc8279b12c4f7bdbbb4270d617e48f51722e4 /node_modules/fast-glob/out/managers/tasks.js
parent412c104bebc507bea9c94fd53b5bdc4b64cbfe31 (diff)
downloadwebsite-3c51c3be85bb0d1bdb87ea0d6632f1c256912f27.tar.gz
website-3c51c3be85bb0d1bdb87ea0d6632f1c256912f27.zip
build: Add some required modules for node
Diffstat (limited to 'node_modules/fast-glob/out/managers/tasks.js')
-rw-r--r--node_modules/fast-glob/out/managers/tasks.js86
1 files changed, 86 insertions, 0 deletions
diff --git a/node_modules/fast-glob/out/managers/tasks.js b/node_modules/fast-glob/out/managers/tasks.js
new file mode 100644
index 0000000..1c5192d
--- /dev/null
+++ b/node_modules/fast-glob/out/managers/tasks.js
@@ -0,0 +1,86 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+var patternUtils = require("../utils/pattern");
+/**
+ * Generate tasks based on parent directory of each pattern.
+ */
+function generate(patterns, options) {
+ var unixPatterns = patterns.map(patternUtils.unixifyPattern);
+ var unixIgnore = options.ignore.map(patternUtils.unixifyPattern);
+ var positivePatterns = getPositivePatterns(unixPatterns);
+ var negativePatterns = getNegativePatternsAsPositive(unixPatterns, unixIgnore);
+ var staticPatterns = positivePatterns.filter(patternUtils.isStaticPattern);
+ var dynamicPatterns = positivePatterns.filter(patternUtils.isDynamicPattern);
+ var staticTasks = convertPatternsToTasks(staticPatterns, negativePatterns, /* dynamic */ false);
+ var dynamicTasks = convertPatternsToTasks(dynamicPatterns, negativePatterns, /* dynamic */ true);
+ return staticTasks.concat(dynamicTasks);
+}
+exports.generate = generate;
+/**
+ * Convert patterns to tasks based on parent directory of each pattern.
+ */
+function convertPatternsToTasks(positive, negative, dynamic) {
+ var positivePatternsGroup = groupPatternsByBaseDirectory(positive);
+ // When we have a global group – there is no reason to divide the patterns into independent tasks.
+ // In this case, the global task covers the rest.
+ if ('.' in positivePatternsGroup) {
+ var task = convertPatternGroupToTask('.', positive, negative, dynamic);
+ return [task];
+ }
+ return convertPatternGroupsToTasks(positivePatternsGroup, negative, dynamic);
+}
+exports.convertPatternsToTasks = convertPatternsToTasks;
+/**
+ * Return only positive patterns.
+ */
+function getPositivePatterns(patterns) {
+ return patternUtils.getPositivePatterns(patterns);
+}
+exports.getPositivePatterns = getPositivePatterns;
+/**
+ * Return only negative patterns.
+ */
+function getNegativePatternsAsPositive(patterns, ignore) {
+ var negative = patternUtils.getNegativePatterns(patterns).concat(ignore);
+ var positive = negative.map(patternUtils.convertToPositivePattern);
+ return positive;
+}
+exports.getNegativePatternsAsPositive = getNegativePatternsAsPositive;
+/**
+ * Group patterns by base directory of each pattern.
+ */
+function groupPatternsByBaseDirectory(patterns) {
+ return patterns.reduce(function (collection, pattern) {
+ var base = patternUtils.getBaseDirectory(pattern);
+ if (base in collection) {
+ collection[base].push(pattern);
+ }
+ else {
+ collection[base] = [pattern];
+ }
+ return collection;
+ }, {});
+}
+exports.groupPatternsByBaseDirectory = groupPatternsByBaseDirectory;
+/**
+ * Convert group of patterns to tasks.
+ */
+function convertPatternGroupsToTasks(positive, negative, dynamic) {
+ return Object.keys(positive).map(function (base) {
+ return convertPatternGroupToTask(base, positive[base], negative, dynamic);
+ });
+}
+exports.convertPatternGroupsToTasks = convertPatternGroupsToTasks;
+/**
+ * Create a task for positive and negative patterns.
+ */
+function convertPatternGroupToTask(base, positive, negative, dynamic) {
+ return {
+ base: base,
+ dynamic: dynamic,
+ patterns: [].concat(positive, negative.map(patternUtils.convertToNegativePattern)),
+ positive: positive,
+ negative: negative
+ };
+}
+exports.convertPatternGroupToTask = convertPatternGroupToTask;