Skip to content

Commit 20b4b56

Browse files
ljharbisaacs
authored andcommitted
[fix] revert all breaking syntax changes
Fixes #153. PR-URL: #154 Credit: @ljharb Close: #154 Reviewed-by: @isaacs
1 parent 2ff0388 commit 20b4b56

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

minimatch.js

+21-20
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
module.exports = minimatch
22
minimatch.Minimatch = Minimatch
33

4-
const path = (() => { try { return require('path') } catch (e) {}})() || {
4+
var path = (function () { try { return require('path') } catch (e) {}}()) || {
55
sep: '/'
66
}
77
minimatch.sep = path.sep
88

9-
const GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
10-
const expand = require('brace-expansion')
9+
var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
10+
var expand = require('brace-expansion')
1111

12-
const plTypes = {
12+
var plTypes = {
1313
'!': { open: '(?:(?!(?:', close: '))[^/]*?)'},
1414
'?': { open: '(?:', close: ')?' },
1515
'+': { open: '(?:', close: ')+' },
@@ -19,22 +19,22 @@ const plTypes = {
1919

2020
// any single thing other than /
2121
// don't need to escape / when using new RegExp()
22-
const qmark = '[^/]'
22+
var qmark = '[^/]'
2323

2424
// * => any number of characters
25-
const star = qmark + '*?'
25+
var star = qmark + '*?'
2626

2727
// ** when dots are allowed. Anything goes, except .. and .
2828
// not (^ or / followed by one or two dots followed by $ or /),
2929
// followed by anything, any number of times.
30-
const twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'
30+
var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'
3131

3232
// not a ^ or / followed by a dot,
3333
// followed by anything, any number of times.
34-
const twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'
34+
var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'
3535

3636
// characters that need to be escaped in RegExp.
37-
const reSpecials = charSet('().*{}+?[]^$\\!')
37+
var reSpecials = charSet('().*{}+?[]^$\\!')
3838

3939
// "abc" -> { a:true, b:true, c:true }
4040
function charSet (s) {
@@ -45,7 +45,7 @@ function charSet (s) {
4545
}
4646

4747
// normalizes slashes.
48-
const slashSplit = /\/+/
48+
var slashSplit = /\/+/
4949

5050
minimatch.filter = filter
5151
function filter (pattern, options) {
@@ -57,7 +57,7 @@ function filter (pattern, options) {
5757

5858
function ext (a, b) {
5959
b = b || {}
60-
const t = {}
60+
var t = {}
6161
Object.keys(a).forEach(function (k) {
6262
t[k] = a[k]
6363
})
@@ -72,16 +72,16 @@ minimatch.defaults = function (def) {
7272
return minimatch
7373
}
7474

75-
const orig = minimatch
75+
var orig = minimatch
7676

77-
const m = function minimatch (p, pattern, options) {
77+
var m = function minimatch (p, pattern, options) {
7878
return orig(p, pattern, ext(def, options))
7979
}
8080

8181
m.Minimatch = function Minimatch (pattern, options) {
8282
return new orig.Minimatch(pattern, ext(def, options))
8383
}
84-
m.Minimatch.defaults = options => {
84+
m.Minimatch.defaults = function defaults (options) {
8585
return orig.defaults(ext(def, options)).Minimatch
8686
}
8787

@@ -175,7 +175,7 @@ function make () {
175175
// step 2: expand braces
176176
var set = this.globSet = this.braceExpand()
177177

178-
if (options.debug) this.debug = (...args) => console.error(...args)
178+
if (options.debug) this.debug = function debug() { console.error.apply(console, arguments) }
179179

180180
this.debug(this.pattern, set)
181181

@@ -267,8 +267,8 @@ function braceExpand (pattern, options) {
267267
return expand(pattern)
268268
}
269269

270-
const MAX_PATTERN_LENGTH = 1024 * 64
271-
const assertValidPattern = pattern => {
270+
var MAX_PATTERN_LENGTH = 1024 * 64
271+
var assertValidPattern = function (pattern) {
272272
if (typeof pattern !== 'string') {
273273
throw new TypeError('invalid pattern')
274274
}
@@ -290,7 +290,7 @@ const assertValidPattern = pattern => {
290290
// of * is equivalent to a single *. Globstar behavior is enabled by
291291
// default, and can be disabled by setting options.noglobstar.
292292
Minimatch.prototype.parse = parse
293-
const SUBPARSE = {}
293+
var SUBPARSE = {}
294294
function parse (pattern, isSub) {
295295
assertValidPattern(pattern)
296296

@@ -710,7 +710,7 @@ function makeRe () {
710710

711711
minimatch.match = function (list, pattern, options) {
712712
options = options || {}
713-
const mm = new Minimatch(pattern, options)
713+
var mm = new Minimatch(pattern, options)
714714
list = list.filter(function (f) {
715715
return mm.match(f)
716716
})
@@ -720,7 +720,8 @@ minimatch.match = function (list, pattern, options) {
720720
return list
721721
}
722722

723-
Minimatch.prototype.match = function match (f, partial = this.partial) {
723+
Minimatch.prototype.match = function match (f, partial) {
724+
if (typeof partial === 'undefined') partial = this.partial
724725
this.debug('match', f, this.pattern)
725726
// short-circuit in the case of busted things.
726727
// comments, etc.

test/partial.js

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ const mm = require('../')
33
t.equal(mm('/a/b', '/*/b/x/y/z', { partial: true }), true)
44
t.equal(mm('/a/b/c', '/*/b/x/y/z', { partial: true }), false)
55
t.equal(mm('/', 'x', { partial: true }), true)
6+
const m = new mm.Minimatch('/*/b/x/y/z')
7+
t.equal(m.match('/a/b', true), true)

0 commit comments

Comments
 (0)