Comparing version 0.1.1 to 0.2.0
@@ -15,4 +15,4 @@ | ||
.replace(globDirsRE, '(.+/)?') | ||
.replace(globAllRE, '(.+/)?*') | ||
.replace(globNamesRE, '[^/]+') | ||
.replace(globAllRE, '(.+/)?([^/]+\/?)') | ||
.replace(globNamesRE, '([^/]+)') | ||
@@ -19,0 +19,0 @@ return new RegExp('^' + pattern + '$') |
{ | ||
"name": "glob-regex", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
# glob-regex v0.1.1 | ||
# glob-regex v0.2.0 | ||
@@ -4,0 +4,0 @@ Convert a glob to a `RegExp` object. |
34
test.js
#!/usr/bin/env node | ||
// @flow | ||
const {test} = require('testpass') | ||
const {test, group} = require('testpass') | ||
@@ -88,1 +88,33 @@ const globRegex = require('.') | ||
}) | ||
// [0] the input | ||
group('capture groups:', () => { | ||
// [1] the filename | ||
test('*.js', (t) => { | ||
const re = globRegex('*.js') | ||
cap(t, re, 'a.js', 'a') | ||
}) | ||
// [1] the directory (or null) | ||
// [2] the filename | ||
test('**.js', (t) => { | ||
const re = globRegex('**.js') | ||
cap(t, re, 'a.js', undefined, 'a') | ||
cap(t, re, 'a/b.js', 'a/', 'b') | ||
}) | ||
// [1] the parent of __tests__ | ||
// [2] the filename | ||
test('**/__tests__/*.js', (t) => { | ||
const re = globRegex('**/__tests__/*.js') | ||
cap(t, re, '__tests__/a.js', undefined, 'a') | ||
cap(t, re, 'a/b/__tests__/c.js', 'a/b/', 'c') | ||
}) | ||
function cap(t, re, input, /*:: ...expected: string[] */) { | ||
const expected = [].slice.call(arguments, 2) | ||
re.lastIndex = 0 | ||
t.eq(re.exec(input), expected) | ||
} | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5120
123