Skip to content

Commit

Permalink
remove dead code, minor re-org
Browse files Browse the repository at this point in the history
  • Loading branch information
jonschlinkert committed Apr 21, 2017
1 parent 75c0628 commit e894de1
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions lib/compilers.js
Expand Up @@ -5,6 +5,7 @@ var extglob = require('extglob');

module.exports = function(snapdragon) {
var compilers = snapdragon.compiler.compilers;
var opts = snapdragon.options;

snapdragon.state = snapdragon.state || {};

Expand All @@ -22,8 +23,8 @@ module.exports = function(snapdragon) {
var dot = compilers.dot;
var eos = compilers.eos;

// register extglob compilers
if (snapdragon.options.noext === true) {
// register extglob compilers or escape exglobs if disabled
if (opts.extglob === false || opts.noext === true) {
snapdragon.compiler.use(escapeExtglobs);
} else {
snapdragon.use(extglob.compilers);
Expand All @@ -49,13 +50,6 @@ module.exports = function(snapdragon) {

// customize end-of-string compiler
.set('eos', function(node) {
if (this.ast.input.slice(-1) !== '/' && this.output.slice(-1) !== '/') {
var suffix = /(\w|\/\])$/.test(this.output) ? '\\/?' : '(\\/|$)';
var len = suffix.length;
if (snapdragon.state.metachar && this.output.slice(-len) !== suffix) {
this.output += suffix;
}
}
if (typeof eos === 'function') {
return eos.apply(this, arguments);
}
Expand All @@ -72,17 +66,23 @@ function escapeExtglobs(compiler) {
return this.emit(val, node);
});

/**
* Visit `node` with the given `fn`
*/

function visit(node, fn) {
if (node.nodes) {
mapVisit(node.nodes, fn);
} else {
fn(node);
}
return node.nodes ? mapVisit(node.nodes, fn) : fn(node);
}

/**
* Map visit over array of `nodes`.
*/

function mapVisit(nodes, fn) {
for (var i = 0; i < nodes.length; i++) {
visit(nodes[i], fn);
var len = nodes.length;
var idx = -1;
while (++idx < len) {
visit(nodes[idx], fn);
}
}
}

0 comments on commit e894de1

Please sign in to comment.