Skip to content

Commit 405d1ec

Browse files
kevlenedjoshwiens
authored andcommitted
feat: Added non-wildcard glob support
Resolves: #88
1 parent 1b2c21a commit 405d1ec

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
"bluebird": "^2.10.2",
2222
"fs-extra": "^0.26.4",
2323
"glob": "^6.0.4",
24+
"is-glob": "^3.1.0",
25+
"loader-utils": "^0.2.15",
2426
"lodash": "^4.3.0",
2527
"minimatch": "^3.0.0",
26-
"node-dir": "^0.1.10",
27-
"loader-utils": "^0.2.15"
28+
"node-dir": "^0.1.10"
2829
},
2930
"scripts": {
3031
"lint": "eslint src/ tests/",

src/preProcessPattern.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import Promise from 'bluebird';
22
import path from 'path';
33
import _ from 'lodash';
4+
import isGlob from 'is-glob';
45

56
const fs = Promise.promisifyAll(require('fs')); // eslint-disable-line import/no-commonjs
67

7-
var isGlobLike = /\*/;
88
// https://www.debuggex.com/r/VH2yS2mvJOitiyr3
99
var isTemplateLike = /(\[ext\])|(\[name\])|(\[path\])|(\[folder\])|(\[emoji(:\d+)?\])|(\[(\w+:)?hash(:\w+)?(:\d+)?\])|(\[\d+\])/;
1010

@@ -57,7 +57,7 @@ export default function preProcessPattern(globalRef, pattern) {
5757
.statAsync(pattern.absoluteFrom)
5858
.catch(() => {
5959
// If from doesn't appear to be a glob, then log a warning
60-
if (isGlobLike.test(pattern.from)) {
60+
if (isGlob(pattern.from)) {
6161
pattern.fromType = 'glob';
6262
} else {
6363
const msg = `unable to locate '${pattern.from}' at '${pattern.absoluteFrom}'`;

tests/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,22 @@ describe('apply function', () => {
209209
.catch(done);
210210
});
211211

212+
it('can use a bracketed glob to move a file to the root directory', (done) => {
213+
runEmit({
214+
expectedAssetKeys: [
215+
'directory/directoryfile.txt',
216+
'directory/nested/nestedfile.txt',
217+
'file.txt',
218+
'noextension'
219+
],
220+
patterns: [{
221+
from: '{file.txt,noextension,directory/**/*}'
222+
}]
223+
})
224+
.then(done)
225+
.catch(done);
226+
});
227+
212228
it('can use a glob object to move a file to the root directory', (done) => {
213229
runEmit({
214230
expectedAssetKeys: [

0 commit comments

Comments
 (0)