Skip to content

Commit

Permalink
Update snapdragon to 0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
danez committed Apr 9, 2018
1 parent b00d865 commit ed10fb2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 23 deletions.
6 changes: 3 additions & 3 deletions lib/compilers.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = function(extglob) {

.set('qmark', function(node) {
var val = '[^\\\\/.]';
var prev = this.prev();
var prev = node.prev;

if (node.parsed.slice(-1) === '(') {
var ch = node.rest.charAt(0);
Expand Down Expand Up @@ -90,7 +90,7 @@ module.exports = function(extglob) {
*/

.set('star', function(node) {
var prev = this.prev();
var prev = node.prev;
var prefix = prev.type !== 'text' && prev.type !== 'escape'
? '(?!\\.)'
: '';
Expand All @@ -103,7 +103,7 @@ module.exports = function(extglob) {
*/

.set('paren', function(node) {
return this.mapVisit(node.nodes);
this.mapVisit(node);
})
.set('paren.open', function(node) {
var capture = this.options.capture ? '(' : '';
Expand Down
2 changes: 2 additions & 0 deletions lib/extglob.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

var Snapdragon = require('snapdragon');
var capture = require('snapdragon-capture');
var define = require('define-property');
var extend = require('extend-shallow');

Expand All @@ -22,6 +23,7 @@ var parsers = require('./parsers');
function Extglob(options) {
this.options = extend({source: 'extglob'}, options);
this.snapdragon = this.options.snapdragon || new Snapdragon(this.options);
this.snapdragon.use(capture());
this.snapdragon.patterns = this.snapdragon.patterns || {};
this.compiler = this.snapdragon.compiler;
this.parser = this.snapdragon.parser;
Expand Down
24 changes: 8 additions & 16 deletions lib/parsers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

var brackets = require('expand-brackets');
var define = require('define-property');
var utils = require('./utils');

/**
Expand Down Expand Up @@ -31,8 +30,7 @@ function parsers(extglob) {
* Extglob open: "*("
*/

.capture('paren.open', function() {
var parsed = this.parsed;
.set('paren.open', function() {
var pos = this.position();
var m = this.match(/^([!@*?+])?\(/);
if (!m) return;
Expand All @@ -43,14 +41,13 @@ function parsers(extglob) {

var open = pos({
type: 'paren.open',
parsed: parsed,
val: val
});

var node = pos({
type: 'paren',
prefix: prefix,
nodes: [open]
nodes: []
});

// if nested negation extglobs, just cancel them out to simplify
Expand All @@ -59,20 +56,16 @@ function parsers(extglob) {
node.prefix = '@';
}

define(node, 'rest', this.input);
define(node, 'parsed', parsed);
define(node, 'parent', prev);
define(open, 'parent', node);

this.pushNode(node, prev);
this.pushNode(open, node);
this.push('paren', node);
prev.nodes.push(node);
})

/**
* Extglob close: ")"
*/

.capture('paren.close', function() {
.set('paren.close', function() {
var parsed = this.parsed;
var pos = this.position();
var m = this.match(/^\)/);
Expand All @@ -95,15 +88,14 @@ function parsers(extglob) {
}

node.prefix = parent.prefix;
parent.nodes.push(node);
define(node, 'parent', parent);
this.pushNode(node, parent);
})

/**
* Escape: "\\."
*/

.capture('escape', function() {
.set('escape', function() {
var pos = this.position();
var m = this.match(/^\\(.)/);
if (!m) return;
Expand All @@ -119,7 +111,7 @@ function parsers(extglob) {
* Question marks: "?"
*/

.capture('qmark', function() {
.set('qmark', function() {
var parsed = this.parsed;
var pos = this.position();
var m = this.match(/^\?+(?!\()/);
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@
},
"dependencies": {
"array-unique": "^0.3.2",
"define-property": "^1.0.0",
"expand-brackets": "^2.1.4",
"extend-shallow": "^2.0.1",
"define-property": "^2.0.2",
"expand-brackets": "^3.0.0",
"extend-shallow": "^3.0.2",
"fragment-cache": "^0.2.1",
"regex-not": "^1.0.0",
"snapdragon": "^0.8.1",
"snapdragon": "^0.11.4",
"snapdragon-capture": "^0.2.0",
"to-regex": "^3.0.1"
},
"devDependencies": {
Expand Down

0 comments on commit ed10fb2

Please sign in to comment.