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 2434d75
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 9 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
52 changes: 50 additions & 2 deletions test/CopyPlugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@ describe('apply function', () => {
'[special?directory]/(special-*file).txt',
'[special?directory]/nested/nestedfile.txt',
'noextension',
'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: [
{
Expand All @@ -384,6 +388,10 @@ describe('apply function', () => {
'nested/[special?directory]/(special-*file).txt',
'nested/[special?directory]/nested/nestedfile.txt',
'nested/noextension',
'nested/symlink/directory-ln/file.txt',
'nested/symlink/directory-ln/nested-directory/file-in-nested-directory.txt',
'nested/symlink/directory/file.txt',
'nested/symlink/directory/nested-directory/file-in-nested-directory.txt',
],
patterns: [
{
Expand All @@ -407,6 +415,7 @@ describe('apply function', () => {
'/some/path/nestedfile.txt.tst',
'/some/path/noextension.tst',
'/some/path/hello.txt.tst',
'/some/path/file-in-nested-directory.txt.tst',
],
patterns: [
{
Expand Down Expand Up @@ -436,6 +445,10 @@ describe('apply function', () => {
'transformed/directory/directoryfile-22af64.txt',
'transformed/directory/nested/nestedfile-d41d8c.txt',
'transformed/noextension-d41d8c',
'transformed/symlink/directory-ln/file-d41d8c.txt',
'transformed/symlink/directory-ln/nested-directory/file-in-nested-directory-d41d8c.txt',
'transformed/symlink/directory/file-d41d8c.txt',
'transformed/symlink/directory/nested-directory/file-in-nested-directory-d41d8c.txt',
],
patterns: [
{
Expand Down Expand Up @@ -567,6 +580,10 @@ describe('apply function', () => {
'[special?directory]/directoryfile.txt',
'[special?directory]/(special-*file).txt',
'[special?directory]/nested/nestedfile.txt',
'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: [
{
Expand All @@ -591,6 +608,10 @@ describe('apply function', () => {
'nested/[special?directory]/directoryfile-22af64.txt',
'nested/[special?directory]/nested/nestedfile-d41d8c.txt',
'nested/noextension-d41d8c',
'nested/symlink/directory-ln/file-d41d8c.txt',
'nested/symlink/directory-ln/nested-directory/file-in-nested-directory-d41d8c.txt',
'nested/symlink/directory/file-d41d8c.txt',
'nested/symlink/directory/nested-directory/file-in-nested-directory-d41d8c.txt',
],
patterns: [
{
Expand Down Expand Up @@ -657,6 +678,24 @@ 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({
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 +1219,7 @@ describe('apply function', () => {
patterns: [
{
from: '**/*',
ignore: ['file.*'],
ignore: ['file.*', 'file-in-nested-directory.*'],
},
],
})
Expand Down Expand Up @@ -1690,6 +1729,10 @@ describe('apply function', () => {
'[special?directory]/(special-*file).txt',
'[special?directory]/nested/nestedfile.txt',
'noextension',
'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',
],
options: {
ignore: ['.dottedfile', '.file.txt'],
Expand Down Expand Up @@ -1753,6 +1796,7 @@ describe('apply function', () => {
],
options: {
ignore: [
'symlink/**/*',
'directory/**/*',
`[[]special${
process.platform === 'win32' ? '' : '[?]'
Expand Down Expand Up @@ -1781,7 +1825,11 @@ describe('apply function', () => {
'noextension',
],
options: {
ignore: ['directory/**/*', '\\[special\\?directory\\]/**/*'],
ignore: [
'symlink/**/*',
'directory/**/*',
'\\[special\\?directory\\]/**/*',
],
},
patterns: [
{
Expand Down
1 change: 1 addition & 0 deletions test/helpers/symlink/directory-ln
Empty file.
Empty file.

0 comments on commit 2434d75

Please sign in to comment.