aboutsummaryrefslogtreecommitdiff
path: root/node_modules/micromatch/lib/compilers.js
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2019-10-06 21:37:45 +0200
committerDimitri Staessens <dimitri@ouroboros.rocks>2019-10-06 21:37:45 +0200
commit3c51c3be85bb0d1bdb87ea0d6632f1c256912f27 (patch)
treec7ccc8279b12c4f7bdbbb4270d617e48f51722e4 /node_modules/micromatch/lib/compilers.js
parent412c104bebc507bea9c94fd53b5bdc4b64cbfe31 (diff)
downloadwebsite-3c51c3be85bb0d1bdb87ea0d6632f1c256912f27.tar.gz
website-3c51c3be85bb0d1bdb87ea0d6632f1c256912f27.zip
build: Add some required modules for node
Diffstat (limited to 'node_modules/micromatch/lib/compilers.js')
-rw-r--r--node_modules/micromatch/lib/compilers.js77
1 files changed, 77 insertions, 0 deletions
diff --git a/node_modules/micromatch/lib/compilers.js b/node_modules/micromatch/lib/compilers.js
new file mode 100644
index 0000000..85cda4f
--- /dev/null
+++ b/node_modules/micromatch/lib/compilers.js
@@ -0,0 +1,77 @@
+'use strict';
+
+var nanomatch = require('nanomatch');
+var extglob = require('extglob');
+
+module.exports = function(snapdragon) {
+ var compilers = snapdragon.compiler.compilers;
+ var opts = snapdragon.options;
+
+ // register nanomatch compilers
+ snapdragon.use(nanomatch.compilers);
+
+ // get references to some specific nanomatch compilers before they
+ // are overridden by the extglob and/or custom compilers
+ var escape = compilers.escape;
+ var qmark = compilers.qmark;
+ var slash = compilers.slash;
+ var star = compilers.star;
+ var text = compilers.text;
+ var plus = compilers.plus;
+ var dot = compilers.dot;
+
+ // register extglob compilers or escape exglobs if disabled
+ if (opts.extglob === false || opts.noext === true) {
+ snapdragon.compiler.use(escapeExtglobs);
+ } else {
+ snapdragon.use(extglob.compilers);
+ }
+
+ snapdragon.use(function() {
+ this.options.star = this.options.star || function(/*node*/) {
+ return '[^\\\\/]*?';
+ };
+ });
+
+ // custom micromatch compilers
+ snapdragon.compiler
+
+ // reset referenced compiler
+ .set('dot', dot)
+ .set('escape', escape)
+ .set('plus', plus)
+ .set('slash', slash)
+ .set('qmark', qmark)
+ .set('star', star)
+ .set('text', text);
+};
+
+function escapeExtglobs(compiler) {
+ compiler.set('paren', function(node) {
+ var val = '';
+ visit(node, function(tok) {
+ if (tok.val) val += (/^\W/.test(tok.val) ? '\\' : '') + tok.val;
+ });
+ return this.emit(val, node);
+ });
+
+ /**
+ * Visit `node` with the given `fn`
+ */
+
+ function visit(node, fn) {
+ return node.nodes ? mapVisit(node.nodes, fn) : fn(node);
+ }
+
+ /**
+ * Map visit over array of `nodes`.
+ */
+
+ function mapVisit(nodes, fn) {
+ var len = nodes.length;
+ var idx = -1;
+ while (++idx < len) {
+ visit(nodes[idx], fn);
+ }
+ }
+}