question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't exclude directories using src glob

See original GitHub issue

I can’t exclude a directory from being copied over when using a src glob. Here’s my task:

gulp.task('copy', function() {
    return gulp.src(['app/**', '!app/_tmp/**'])
        .pipe(gulp.dest('dist'));
});

Gulp copies over app/**, but app/_tmp/ is still being copied.

Expected:

+ app/
  + tmp/
      file1
      file2
  + css/
      styles.css
  + js/
      app.js
+ dist/
  + css/
      styles.css
  + js/
      app.js

Gulp output:

+ app/
  + tmp/
      file1
      file2
  + css/
      styles.css
  + js/
      app.js
+ dist/
  + tmp/
  + css/
      styles.css
  + js/
      app.js

Update: Clarified that the dist/_tmp/ directory does not contain any files

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:28 (9 by maintainers)

github_iconTop GitHub Comments

76reactions
stryjucommented, Jan 17, 2014

@aaronbushnell

gulp.src(['app/**', '!app/{_tmp,_tmp/**}'])

why?

  • !app/_tmp would match only the folder, but not any file within it - since it’s not a globbing expression (a bug?)
  • !app/_tmp/** would match the files IN the _tmp folder, but not the folder itself, so the empty folder would be created

using the !app/{_tmp,_tmp/**} pattern uses a pattern to combine the both requirements and says:

give me all the dirs/files in app folder EXCEPT for _tmp folder content and the _tmp directory itself

😃

66reactions
gfloydcommented, Jan 17, 2014

The way I’ve made this work is to exclude the directory and the contents like so: gulp.src(['app/**', '!app/_tmp', '!app/_tmp/**'])

Read more comments on GitHub >

github_iconTop Results From Across the Web

gulp.src() include files but ignore all folders - Stack Overflow
What globbing pattern to include all the files in a folder but ignore ALL subfolders? gulp.src('*') includes all files and folders. I just...
Read more >
rsync exclude directory not working - Unix Stack Exchange
FYI my issue was using the list syntax --exclude={'landing','studio'} and I had a space after the , . The list must not contain...
Read more >
Exclude Directory-Pattern in gulp with glob in `gulp.src`
ay you have a folder project/src that contains the following files:. “Exclude Directory-Pattern in gulp with glob in `gulp.src`” is published by jack.yin....
Read more >
Working With Files - Gradle User Manual
You can include files in subdirectories by using an Ant-style glob pattern ... fileTree(dir: 'src/main') // Add include and exclude patterns to the...
Read more >
glob - npm
nodir Do not match directories, only files. (Note: to match only directories, simply put a / at the end of the pattern.) ignore...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found