Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I wonder if it is possible not to copy a file when it conforms to a set of regular expressions #47

Open
SuGod opened this issue May 23, 2020 · 7 comments

Comments

@SuGod
Copy link

SuGod commented May 23, 2020

copy({
  targets: [{ src: 'src/*', exclude: ['*.md', 'demo'], dest: 'dist' }],
})
@truesilver92
Copy link

not using regular expressions, but using glob syntax from main readme

@pancake-boy
Copy link

the negate pattern doesn't seem to work.
it just copies all files.

copy({ targets: [ { src: ['!**/*.scss', '!**/*.svg', 'src/themes/**/*'], dest: 'lib' }, ], flatten: false, }),

@ivanjonas
Copy link

@pancake-boy I believe it's a question of order. the negation patterns exclude previously matched files. Try putting the 'src/themes/**/*' first in the array.

@brgrz
Copy link

brgrz commented Apr 15, 2021

@pancake-boy I believe it's a question of order. the negation patterns exclude previously matched files. Try putting the 'src/themes/**/*' first in the array.

I can't get the negated patterns to work 100% either. Tried a bunch of different ways

copy({ targets: [{ src: ['public/*', '!public/tiles'], dest: OUT_DIR }] }),
this works, will skip tiles directory

copy({ targets: [{ src: ['public/*', '!*.map', '!public/tiles'], dest: OUT_DIR }] }),
this doesn't skip .map files but does skip tiles directory

copy({ targets: [{ src: ['public/*', '!**/*.map', '!public/tiles'], dest: OUT_DIR }] }),
this is the example from the Readme and it does not skip .map files

copy({ targets: [{ src: ['public/*', '!public/**/*.map', '!public/tiles'], dest: OUT_DIR }] }),
this also does not skip .map files

@brgrz
Copy link

brgrz commented Apr 15, 2021

Also negated pattern with template literals don't work either
copy({ targets: [{ src: [`${PUBLIC_ASSETS_DIR}/*`, `!${PUBLIC_ASSETS_DIR}}/tiles`], dest: OUT_DIR }] })

@Junior2Ran
Copy link

negated patterns not work + 1
{src: ['src/data', '!src/data/geojson'], dest: 'dist'}

@samisayegh
Copy link

To use negated patterns, I needed to specify the expandDirectories and onlyFiles options to true.

copy({
    targets: [
      {
        src: ['src/', '!src/**/*.test.ts'],
        dest: 'dist/browser/src/',
        expandDirectories: true,
        onlyFiles: true,
      },
    ],
    flatten: false,
  });

These options are intentionally being set to false here. Perhaps there is a good reason for these defaults? If so, maybe just adjusting this README.md example could be enough,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants