Nodemon ignore folder using regex expressions - regex

In Nodemon ignore file I want to selectively ignore the folders from my main folder.
My folder structure is :
-modules
-accounts
-client
-angularfiles
-accounts.js
-repository
-accountrepository.js
-bankbranch
-client
-angularfiles
-bankbranch.js
-repository
-bankbranchrepository.js
In this hierarchy I want to ignore file paths "modules/accounts/client/angularfiles/" &
"modules/bankbranch/client/angularfiles/"
I have many more such modules. In this case I tried writing this regex to ignore based on the expression like so :
/modules\\\w*\\client\\angularfiles\\*/
Using the online regex matcher it matches this path :
\AngularJSApp\modules\accounts\client\angularfiles\bankbranch.js
but nodemon restarts when the file in client\angularfiles is changed.

Nodemon relies on file patterns rather than regular expressions for ignoring some files.
Try this instead:
nodemon --ignore 'modules/**/client/angularfiles/*'

Related

Replacing XML content with Regular Expressions and SED

I have a project that's effectively 2 maven projects. In the "child" maven project I have a property that references the version in the parent project:
<myparent.project.version>15.0.0-SNAPSHOT</myparent.project.version>
What I'm trying to do is bash script a few common commands together, i.e. when creating a release branch I want to create one of the parent maven project, then update the child maven parent project but Im missing how to update this value:
I'm hoping to get something along the lines of working:
where newVersion = 16.0.0
$ sed -i "s/\<myparent.project.version\>[0-9.]+-SNAPSHOT\<\/myparent.project.version\>/<myparent.project.version>$newVersion-SNAPSHOT<\/myparent.project.version>/g" pom.xml
I have checked the regex (\<myparent.project.version\>[0-9.]+-SNAPSHOT\<\/myparent.project.version\>) with https://regex101.com/ and it matches the line I want to replace in my pom.xml file, but for some reason, I can't get the sed to work correctly.
Any ideas?
You should use an xml parser like XMLStarlet. That said, for that simple substitution, you can try this GNU sed:
sed "s/<myparent\.project\.version>[0-9.]\+-SNAPSHOT<\/myparent\.project\.version>/<myparent.project.version>$newVersion-SNAPSHOT<\/myparent.project.version>/g" file
You must escape the one or more quantifier: \+ and the dot: \. but not the < nor >(\< and \> are used for word boundaries with GNU sed)

How to use the exclude_files regex in cpplint?

I am using cpplint to check my sourcode agains the google style guide.
Cpplint's help says:
cpplint.py supports per-directory configurations specified in CPPLINT.cfg
files. CPPLINT.cfg file can contain a number of key=value pairs.
Currently the following options are supported:
"exclude_files" allows to specify a regular expression to be matched against
a file name. If the expression matches, the file is skipped and not run
through liner.
Example file:
filter=-build/include_order,+build/include_alpha
exclude_files=.*\.cc
The above example disables build/include_order warning and enables
build/include_alpha as well as excludes all .cc from being
processed by linter, in the current directory (where the .cfg
file is located) and all sub-directories.
How I use cpplint:
I use cpplint by this command to check all files in my source folder:
cpplint src/*.c
Well there is one special file foo.cc which must not be checked. So I tried to create a CPPLIN.cfg to use the exclude_files property. My file looks like this:
set noparent
filter=-build/include_dir
exclude_files=foo.cc
Nevertheless foo.cc is still checked.
What I have already tried to do:
I tried exclude_files=/.*\.cc/. This should exclude all files ending with *.cc. Nevertheless all files are still checked.
I tried to remove my filter from the file. This caused more errors than before. So I am now sure that my CPPLINT.cfg file is found by cpplint.
Question:
How to use the exclude_files regex in cpplint correctly?
Turns out apparently that the doc is wrong: exclude_files only excludes files in the same directory as CPPLINT.cfg, not in subdirectories. See https://github.com/google/styleguide/issues/220
So the solution would be to create src/CPPLINT.cfg and put exclude_files=.*\.cc in it.

hgignore regex expression for excluding all files except 1 folder

I'm trying to ignore all .SQL files, except if they are under the DatabaseSchema folder.
This is the regex expression I came up with:
^(?!DatabaseSchema\\).*\.sql$
This seems to work on all the regex testing sites (for example http://regexr.com/ and https://regex101.com/) but when I run it through mercurial it doesn't ignore either of these test files:
DatabaseSchema\test.sql
testRoot.sql
I'm using syntax: glob at the start of my hgignore before switching to regex at the end for this 1 case by using "syntax: regex".
Is there something I'm missing about the way mercurial uses regex in the hgignore file?

hg: how to exclude "*.xll" file but not xll directory

In my .hgignore file, I am trying to ignore all generated xll files. I (unfortunately) have a directory called "xll" within the domain of the repository, and I do not want to ignore the directory itself.
I have tried:
syntax: regex
\.xll$
which I thought should mean "match all that ends in '.xll'"
and
syntax: regex
*.\.xll$
which I thought should mean "match all that have at least one arbitrary character, followed by '.xll'".
With either of the above, the directory is not ignored (yay) but neither is a file foobar.xll (darn). If I use a bare "xll" with regex, or "*.xll" with glob, both the directory and the file are ignored.
This is in linux (Ubuntu 10.04.4) with hg 2.6 (TortoiseHG 2.8) (I'm observing the effect in Nautilus via the presence or absence of "X" icons).
Thanks in advance!
EDIT
(adding comments in here as they are too long to fit in a comment...)
Thanks for all the responses. Turns out I was misinterpreting some things. So:
- because I used "regex" instead of "regexp" (and I had "glob" at top of file), whatever I put on the line that referred to "xll" was being interpreted by "glob", so the line did have an effect (which made me think, incorrectly, that the "syntax: regex" line was doing what I thought it was
- by coincidence, all the files in my "xll" directory were filtered out (as they should have been) by other lines in .hgignore, and not by the "*.xll" line
- consequently, in Nautilus, the xll directory was marked as "ignored", not because the filter ignoring the entire directory, but instead because other filters were filtering all files within that directory
Bottom line, the *.xll I had under "syntax: glob" was actually filtering out files exactly as desired. The feedback in Nautilus was just different than I expected.
It's .*\.xll$, not *.\.xll$.
Using glob syntax works well for me:
syntax: glob
*.xll
When I create a directory named xll with an untracked file, I still see the file in the output from hg status:
$ mkdir xll
$ touch a.xll x.txt xll/b.xll xll/y.txt
$ echo 'syntax: glob\n*.xll' > .hgignore
$ hg status
? .hgignore
? x.txt
? xll/y.txt
Using \.xll$ with syntax: regexp also works great for me.

ignoring folders in mercurial

Caveat:
I try all the posibilities listed here: How can I ignore everything under a folder in Mercurial.
None works as I hope.
I want to ignore every thing under the folder test. But not ignore srcProject\test\TestManager
I try
syntax: glob
test/**
And it ignores test and srcProject\test\TestManager
With:
syntax: regexp
^/test/
It's the same thing.
Also with:
syntax: regexp
test\\*
I have install TortoiseHG 0.4rc2 with Mercurial-626cb86a6523+tortoisehg, Python-2.5.1, PyGTK-2.10.6, GTK-2.10.11 in Windows
Try it without the slash after the caret in the regexp version.
^test/
Here's a test:
~$ mkdir hg-folder-ignore
~$ cd hg-folder-ignore
~/hg-folder-ignore$ echo '^test/' > .hgignore
~/hg-folder-ignore$ hg init
~/hg-folder-ignore$ mkdir test
~/hg-folder-ignore$ touch test/ignoreme
~/hg-folder-ignore$ mkdir -p srcProject/test/TestManager
~/hg-folder-ignore$ touch srcProject/test/TestManager/dont-ignore
~/hg-folder-ignore$ hg stat
? .hgignore
? srcProject/test/TestManager/dont-ignore
Notice that ignoreme isn't showing up and dont-ignore is.
Both cases worked for me (on linux and windows):
syntax: regexp
^backup/ #root folder
nbproject/ #any folder
or
syntax: glob
./backup/* #root folder
nbproject/* #any folder
However, it wasn't before I added a link to .hgignore file to .hgrc file in my repo:
[ui]
ignore = .hg/.hgignore
Also worth mentioning that mercurial ignores files that it is not currently tracking, which are those added before you configured it to ignore them. So, don't be put off by hg status saying some filed are M (modified) or ! (missing) in the folders that you have just added to the ignore list!
You can use zero-width negative look-ahead and look-behind assertions to specify that you want to ignore test only when it's not preceded by srcProject and not followed by TestManager:
syntax: regexp
(?<!srcProject\\)test\\(?!TestManager)
Mercurial uses Python regular expressions, so you can find more info on zero-width assertions in the Python docs: https://docs.python.org/library/re.html#regular-expression-syntax
Create .hgignore file under root directory of the repository
Now add the following contents in the file .
syntax: glob
bin/**
*.DS_Store
This will remove the bin directory and all the *.DS_Store files from the repository