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

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"

Related

renaming multiple sequential files extension

I have multiple sequential files naming in one directory with multiple incremental files extension. My objective is using rename command to rename just the file extension.
IBM0020.DAT_001
IBM0020.DAT_002
IBM0020.DAT_003
IBM0021.DAT_001
IBM0021.DAT_002
IBM0022.DAT_001
IBM0022.DAT_002
IBM0022.DAT_003
IBM0022.DAT_004
...
to
IBM0020.DAT_001
IBM0020.DAT_002
IBM0020.DAT_003
IBM0021.DAT_004
IBM0021.DAT_005
IBM0022.DAT_006
IBM0022.DAT_007
IBM0022.DAT_008
IBM0022.DAT_009
...
I have dry run the command below, but not the expected result. I want to retain the filename and only rename/change the extension with running number sequence.
rename -n 's/.+/our $i;sprintf(".DAT_%03d",1+$i++)/e' *
IBM0020.DAT_001 renamed as .DAT_001
IBM0020.DAT_002 renamed as .DAT_002
IBM0020.DAT_003 renamed as .DAT_003
IBM0021.DAT_001 renamed as .DAT_004
IBM0021.DAT_002 renamed as .DAT_005
IBM0022.DAT_001 renamed as .DAT_006
IBM0022.DAT_002 renamed as .DAT_007
IBM0022.DAT_003 renamed as .DAT_008
IBM0022.DAT_004 renamed as .DAT_009
Thanks for any help.
Continuing from the comment, if all of your files have .DAT_XXX as the extension you wish to rename sequentially, then there is no need to include ".DAT_" as part of the pattern you are matching. Simply match the 3-digits at the end of the filename and change those, e.g.
rename 's/\d{3}$/our $i; sprintf("%03d", 1+$i++)/e' *
If ".DAT_" isn't unique, and you have other extensions ending in 3-digits you want to avoid renaming, then you can include "DAT_" as part of the pattern matched and replaced, e.g.
rename -n 's/DAT_\d{3}/our $i; sprintf("DAT_%03d", 1+$i++)/e' *
(note: there are two different "rename" utilities in common use on Linux, the first provided as part of the util-linux package does not support regex renaming, and then perl-rename, which you have, that does support perl-regex renaming.)

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.

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

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

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'))

What does ** mean in a path?

ive been setting up Grunt for my web app to auto build it and im seeing paths like
/path/to/file/**/*.js
i understand what one wildcard means, but what does 2 in a row mean?
/path/to/file/**/*.js matches any number of directories between /path/to/file/ and /*.js. As opposed to /path/to/file/*/*.js, which matches a single directory between /path/to/file/ and /*.js.
this matchers called "glob pattern" they are widely used in shell script and in CLI tools like grunt or npm .they '**' means -- "Matches zero or more directories, but will never match the directories . and .. "
you can read more in the docs
glob pattern

Resources