Skip to content

Commit fe13b3a

Browse files
committed
Fix nested directories in blobs
Resolves: #24
1 parent b10bb65 commit fe13b3a

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,13 @@ export default (patterns = [], options = {}) => {
5656
Promise.each(patterns, (pattern) => {
5757
let relDest;
5858
let globOpts;
59-
let context;
60-
const ignoreList = webpackIgnore.concat(pattern.ignore || []);
6159

6260
if (pattern.context && !path.isAbsolute(pattern.context)) {
6361
pattern.context = path.resolve(webpackContext, pattern.context);
6462
}
65-
66-
context = pattern.context || webpackContext;
63+
64+
const context = pattern.context || webpackContext;
65+
const ignoreList = webpackIgnore.concat(pattern.ignore || []);
6766

6867
globOpts = {
6968
cwd: context
@@ -112,8 +111,11 @@ export default (patterns = [], options = {}) => {
112111
}
113112

114113
return globAsync(relSrc, globOpts)
115-
.each((relFileSrc) => {
114+
.each((relFileSrcParam) => {
116115
let relFileDest;
116+
let relFileSrc;
117+
118+
relFileSrc = relFileSrcParam;
117119

118120
// Skip if it matches any of our ignore list
119121
if (shouldIgnore(relFileSrc, ignoreList)) {

src/writeFileToAssets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default (opts) => {
2020
return fs
2121
.statAsync(absFileSrc)
2222
.then((stat) => {
23-
if (!copyUnmodified && stat.mtime.getTime() < lastGlobalUpdate) {
23+
if (stat.isDirectory() || !copyUnmodified && stat.mtime.getTime() < lastGlobalUpdate) {
2424
return null;
2525
}
2626

tests/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,9 @@ describe('apply function', () => {
281281
],
282282
patterns: [{
283283
context: 'directory',
284+
flatten: true,
284285
from: '**/*.txt',
285-
to: 'nested',
286-
flatten: true
286+
to: 'nested'
287287
}]
288288
})
289289
.then(done)
@@ -665,9 +665,9 @@ describe('apply function', () => {
665665
'newdirectory/nestedfile.txt'
666666
],
667667
patterns: [{
668+
flatten: true,
668669
from: 'directory',
669-
to: 'newdirectory',
670-
flatten: true
670+
to: 'newdirectory'
671671
}]
672672
})
673673
.then(done)

0 commit comments

Comments
 (0)