Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore "./*.json" should ignore json files from current working directory #1784

Closed
piotrminkina opened this issue Oct 17, 2020 · 5 comments · Fixed by #1787, elirehema/pcapi#23 or elirehema/real-estate#34 · May be fixed by TheDogenode/torrent-aio-bot#4
Labels
bug confirmed bug has PR

Comments

@piotrminkina
Copy link

Hello,

Thanks for great software :) I noticed a problem with ignore files from current working directory. Nodeman restarts my application unexpectedly despite ignore "./*.json".

  • nodemon -v: 2.0.5
  • node -v: v12.18.4
  • Operating system/terminal environment: Ubuntu 20.04.1 LTS on Kernel 5.4.0-51-generic
  • Using Docker? What image: andyrbell/mountebank:2.3.2 with added RUN npm install -g nodemon to local Dockerfile
  • Command you ran: nodemon --verbose config.json.ejs

nodeman.json

{
  "_comment": "See https://github.com/remy/nodemon",
  "ext": "js,json,ejs",
  "ignore": [
    "var/",
    "./*.json"
  ],
  "execMap": {
    "ejs": "mb start --logfile=var/mb.log --pidfile=var/mb.pid --allowInjection --debug --configfile"
  }
}

Expected behaviour

touch anyfile.json — nodeman should ignore this change
touch any-not-ignored-dir/anyfile.json — nodeman restarts mountebank as expected

Actual behaviour

touch anyfile.json — nodeman restarts mountebank unexpectedly

Logs present the problem

mountebank_1  | [nodemon] 2.0.5
mountebank_1  | [nodemon] reading config ./nodemon.json
mountebank_1  | [nodemon] to restart at any time, enter `rs`
mountebank_1  | [nodemon] or send SIGHUP to 1 to restart
mountebank_1  | [nodemon] ignoring: ./var/**/* ./*.json
mountebank_1  | [nodemon] watching path(s): *.*
mountebank_1  | [nodemon] watching extensions: js,json,ejs
mountebank_1  | [nodemon] starting `mb start --logfile=var/mb.log --pidfile=var/mb.pid --allowInjection --debug --configfile config.json.ejs`
mountebank_1  | [nodemon] spawning
mountebank_1  | [nodemon] child pid: 17
mountebank_1  | [nodemon] watching 6 files
mountebank_1  | warn: [mb:2525] Running with --allowInjection set. See http://localhost:2525/docs/security for security info
mountebank_1  | info: [mb:2525] mountebank v2.3.2 now taking orders - point your browser to http://localhost:2525/ for help
mountebank_1  | info: [mb:2525] PUT /imposters
mountebank_1  | info: [https:8443 nokia-altiplano] Open for business...

Now I'm execute this command: touch anyfile.json (nodeman restarts mountebank unexpectedly)

mountebank_1  | [nodemon] files triggering change check: anyfile.json
mountebank_1  | [nodemon] matched rule: **/*.*
mountebank_1  | [nodemon] changes after filters (before/after): 1/1
mountebank_1  | [nodemon] restarting due to changes...
mountebank_1  | [nodemon] anyfile.json
mountebank_1  | 
mountebank_1  | [nodemon] starting `mb start --logfile=var/mb.log --pidfile=var/mb.pid --allowInjection --debug --configfile config.json.ejs`
mountebank_1  | [nodemon] spawning
mountebank_1  | [nodemon] child pid: 37
mountebank_1  | warn: [mb:2525] Running with --allowInjection set. See http://localhost:2525/docs/security for security info
mountebank_1  | info: [mb:2525] mountebank v2.3.2 now taking orders - point your browser to http://localhost:2525/ for help
mountebank_1  | info: [mb:2525] PUT /imposters
mountebank_1  | info: [https:8443 nokia-altiplano] Open for business...

Now I'm execute this command: touch any-not-ignored-dir/anyfile.json (nodeman restarts mountebank as expected)

mountebank_1  | [nodemon] files triggering change check: any-not-ignored-dir/anyfile.json
mountebank_1  | [nodemon] matched rule: **/*.*
mountebank_1  | [nodemon] changes after filters (before/after): 1/1
mountebank_1  | [nodemon] restarting due to changes...
mountebank_1  | [nodemon] any-not-ignored-dir/anyfile.json
mountebank_1  | 
mountebank_1  | [nodemon] starting `mb start --logfile=var/mb.log --pidfile=var/mb.pid --allowInjection --debug --configfile config.json.ejs`
mountebank_1  | [nodemon] spawning
mountebank_1  | [nodemon] child pid: 52
mountebank_1  | warn: [mb:2525] Running with --allowInjection set. See http://localhost:2525/docs/security for security info
mountebank_1  | info: [mb:2525] mountebank v2.3.2 now taking orders - point your browser to http://localhost:2525/ for help
mountebank_1  | info: [mb:2525] PUT /imposters
mountebank_1  | info: [https:8443 nokia-altiplano] Open for business...

Regards
Piotr Minkina

@remy
Copy link
Owner

remy commented Oct 17, 2020

What happens if you remove json from the ext list?

@piotrminkina
Copy link
Author

When I remove json from ext list, then the following results will happen:

touch anyfile.json emits the following logs:

mountebank_1  | [nodemon] files triggering change check: anyfile.json
mountebank_1  | [nodemon] matched rule: **/*.*
mountebank_1  | [nodemon] changes after filters (before/after): 1/0

touch any-not-ignored-dir/anyfile.json emits the following logs:

mountebank_1  | [nodemon] files triggering change check: any-not-ignored-dir/anyfile.json
mountebank_1  | [nodemon] matched rule: **/*.*
mountebank_1  | [nodemon] changes after filters (before/after): 1/0

Summing up, all JSON files are ignored by nodemon.

Regards
Piotr Minkina

@remy
Copy link
Owner

remy commented Oct 19, 2020

Oh, to try to clarify, are you trying to ignore json files in the CWD, but still watch json files that are nested further down?

remy added a commit that referenced this issue Oct 19, 2020
Fixes: #1784

This fixes the watch/ignore rules where the config is ignoring
the relative local path of ./ - this fix was in place for the
positive (watch) test but not patched for the negative (ignore).
@remy remy added bug confirmed bug has PR labels Oct 19, 2020
@piotrminkina
Copy link
Author

Exactly. This is because mb save by default creates mb.json at current working directory, so without ignore ./*.json mountebank will be restarted by nodemon unexpectedly (e.g. all in memory data, including state will be lost).

remy added a commit that referenced this issue Oct 19, 2020
Fixes: #1784

This fixes the watch/ignore rules where the config is ignoring
the relative local path of ./ - this fix was in place for the
positive (watch) test but not patched for the negative (ignore).
@remy
Copy link
Owner

remy commented Oct 19, 2020

This fix has been merged into master and is being built and deployed now. Look out for the next version shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment