Skip to content

Commit

Permalink
feat: supports copy nested directories/files in symlink
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Feb 18, 2019
1 parent 49a28f0 commit 6e1b1fb
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 8 deletions.
28 changes: 21 additions & 7 deletions package-lock.json

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

1 change: 1 addition & 0 deletions src/processPattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default function processPattern(globalRef, pattern) {
const globOptions = Object.assign(
{
cwd: pattern.context,
follow: true,
},
pattern.globOptions || {}
);
Expand Down
35 changes: 34 additions & 1 deletion test/CopyPlugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ describe('apply function', () => {
// Get a mock compiler to pass to plugin.apply
const compiler = opts.compiler || new MockCompiler();

const isWin = process.platform === 'win32';

if (!opts.symlink || isWin) {
if (!opts.options) {
opts.options = {};
}

if (!opts.options.ignore) {
opts.options.ignore = [];
}

opts.options.ignore.push('symlink/**/*');
}

new CopyPlugin(opts.patterns, opts.options).apply(compiler);

// Call the registered function with a mock compilation and callback
Expand Down Expand Up @@ -657,6 +671,25 @@ describe('apply function', () => {
.then(done)
.catch(done);
});

it('can use a glob to move a file to the root directory with symbolic link', (done) => {
runEmit({
symlink: true,
expectedAssetKeys: [
'symlink/directory-ln/file.txt',
'symlink/directory-ln/nested-directory/file-in-nested-directory.txt',
'symlink/directory/file.txt',
'symlink/directory/nested-directory/file-in-nested-directory.txt',
],
patterns: [
{
from: 'symlink/**/*.txt',
},
],
})
.then(done)
.catch(done);
});
});

describe('with file in from', () => {
Expand Down Expand Up @@ -1180,7 +1213,7 @@ describe('apply function', () => {
patterns: [
{
from: '**/*',
ignore: ['file.*'],
ignore: ['file.*', 'file-in-nested-directory.*'],
},
],
})
Expand Down
1 change: 1 addition & 0 deletions test/helpers/symlink/directory-ln
Empty file.
Empty file.

0 comments on commit 6e1b1fb

Please sign in to comment.