With Gulp is there a way I can exclude a folder from gulp.src? - node.js

I have this gulp:
return gulp.src('content/less/*/*.less')
Is there a way that I could exclude the folder
content/less/info from the .src search?

A glob that begins with ! excludes matching files from the glob results up to that point. For example:
The following expression matches a.js and bad.js:
gulp.src(['client/*.js', '!client/b*.js', 'client/bad.js'])
Ref: https://github.com/gulpjs/gulp/blob/master/docs/API.md#globs

Related

jest collectCoverageFrom glob string that ignores files ending with module.ts but contains *.ts

I am trying to configure collectCoverageFrom for jest to look up all my .ts files expect those with .module.ts but I can not find the correct glob pattern.
As peer what I understand this should work :
src/**/**.!(.module.ts).ts
but for some reason it does not takes files like this one:
src/pages/home/home.ts
What I am doing wrong?
Try this
src/**/!(*module)*.ts
You can test this glob pattern using globster https://globster.xyz/?q=**%2F!(module).ts
The solution was to use two rules ['src/**/*.ts','!**/*.module.ts']].
Looks like the second rule filters the first rule results: "Take all the *.ts files except(!) *.module.ts"

glob for all folders within a folder except one named folder

I am writing my Karma conf based on
http://karma-runner.github.io/1.0/config/preprocessors.html
The key for the preprocessor is a glob string.
This works for all folders within the build folder:
build/**/!(*.spec|*.bundle|*.min).js
However, I don't want all folders. I wanted folder 1,2,4,5 NOT folder 3
Can I write that in a single string (as seems to be required by karma)?
Something like
build/(folder1|folder2|folder4|folder5)/!(*.spec|*.bundle|*.min).js
or even better
build/** but not folder 3/!(*.spec|*.bundle|*.min).js
This covers it
https://github.com/karma-runner/karma-coverage/issues/13
Quoting it
You can make this work using brace expansion. For #chevalric's case, the following pattern will do it:
src/*/{*.js,!(test)/**/*.js}
This expands to two patterns:
src/*/*.js # Match files in the module root
src/*/!(test)/**/*.js # Match files in all subfolders except test/
Also it later says ..
src/*/!(test)/**/*.js
worked
However, for me, I could not test that this worked for various reasons.

Is there a difference 'app/**/*.html' and 'app/**/**/*.html' as a gulp.src file list?

My config file for gulp watch looks like this:
var files = [
'app/**/*.html',
'app/**/**/*.html',
'app/**/**/**/*.html'
];
I'm confused about the difference with ** and *
Could all of these be just one line if I use ** ?
The pattern is call "globbing". Gulp-watch uses the "node-glob" module for that:
https://github.com/isaacs/node-glob#glob-primer
* Matches 0 or more characters in a single path portion
** If a "globstar" is alone in a path portion, then it matches zero or more directories and subdirectories searching for matches. It does not crawl symlinked directories.
So, in your case the three patterns are redundant, they would produce the same fileset.
To be short
** represents all Folder
*.js represents all File with .js extension
*.* represents all file with any extension
https://www.npmjs.com/package/glob#glob-primer

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?
You are close. Try this
gulp.src(['./assets/**/!(*.coffee|*.scss)', '!assets/images'])
.pipe(gulp.dest('.tmp/public'))

the_silver_searcher: Don't search in files that have the filename X.

I'm using ag (https://github.com/ggreer/the_silver_searcher/blob/master/doc/ag.1.md) to search for a pattern in a directory.
What I'd like to do is:
ag SearchPattern --excludeFilesThatHaveThisIntheFileName *Test
is that possible?
The option you are looking for is --ignore. From the man page:
--ignore PATTERN:
Ignore files/directories matching this pattern.
Literal file and directory names are also allowed.
After testing it, it seems the pattern must be a file glob instead of a regular expression.
Your line would then become:
ag SearchPattern --ignore *Test

Resources