Search code examples
node.jsgulpglobnode-glob

Globbing for double extension files


I have this Gulp snippet:

gulp.src(['./assets/**/*.!(coffee|scss)', '!assets/images{,/**}'])
    .pipe(gulp.dest('.tmp/public'))

And this folder structure:

  • assets
    • js
      • A.coffee
      • A.B.coffee
      • A.B.C.coffee
      • X.js

The intention is to copy everything except:

  • the contents of assets/images
  • any and all CoffeeScript files

However, this glob pattern does not exclude A.B and A.B.C.coffee.

What is the correct pattern to do this?


Solution

  • You are close. Try this

    gulp.src(['./assets/**/!(*.coffee|*.scss)', '!assets/images'])
        .pipe(gulp.dest('.tmp/public'))