Skip to content

Commit

Permalink
fix: copying same file to multiple targets (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored and joshwiens committed Nov 17, 2017
1 parent 1ceee6c commit 43a9870
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 22 deletions.
40 changes: 20 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions src/writeFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,17 @@ export default function writeFile(globalRef, pattern, file) {
}

if (!copyUnmodified &&
written[file.absoluteFrom] && written[file.absoluteFrom][hash]) {
written[file.absoluteFrom] &&
written[file.absoluteFrom]['hash'] === hash &&
written[file.absoluteFrom]['webpackTo'] === file.webpackTo
) {
info(`skipping '${file.webpackTo}', because it hasn't changed`);
return;
} else {
debug(`added ${hash} to written tracking for '${file.absoluteFrom}'`);
written[file.absoluteFrom] = {
[hash]: true
hash: hash,
webpackTo: file.webpackTo
};
}

Expand Down
18 changes: 18 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,24 @@ describe('apply function', () => {
.then(done)
.catch(done);
});

it('same file to multiple targets', (done) => {
runEmit({
expectedAssetKeys: [
'first/file.txt',
'second/file.txt'
],
patterns: [{
from: 'file.txt',
to: 'first/file.txt'
}, {
from: 'file.txt',
to: 'second/file.txt'
}]
})
.then(done)
.catch(done);
});
});

describe('with directory in from', () => {
Expand Down

0 comments on commit 43a9870

Please # to comment.