Showing preview only (355K chars total). Download the full file or copy to clipboard to get everything.
Repository: remy/nodemon
Branch: main
Commit: c6dd371093f4
Files: 161
Total size: 320.9 KB
Directory structure:
gitextract_bisxif4y/
├── .eslintrc.json
├── .github/
│ ├── CONTRIBUTING.md
│ ├── FUNDING.yml
│ ├── ISSUE_TEMPLATE/
│ │ └── bug_report.md
│ ├── ISSUE_TEMPLATE.md
│ ├── no-response.yml
│ ├── oliver.yml
│ └── workflows/
│ ├── commits.yml
│ ├── node.js.yml
│ ├── release.yml
│ ├── stale.yml
│ └── website.yml
├── .gitignore
├── .jshintrc
├── .npmignore
├── .npmrc
├── .prettierrc.json
├── .releaserc
├── .travis.yml
├── CODE_OF_CONDUCT.md
├── Dockerfile
├── LICENSE
├── README.md
├── TODO.md
├── bin/
│ └── nodemon.js
├── commitlint.config.js
├── doc/
│ ├── arch.md
│ ├── cli/
│ │ ├── authors.txt
│ │ ├── config.txt
│ │ ├── help.txt
│ │ ├── logo.txt
│ │ ├── options.txt
│ │ ├── topics.txt
│ │ ├── usage.txt
│ │ └── whoami.txt
│ ├── events.md
│ ├── option-parsing-logic.md
│ ├── requireable.md
│ ├── rules.md
│ └── sample-nodemon.md
├── faq.md
├── index.d.ts
├── jsconfig.json
├── lib/
│ ├── cli/
│ │ ├── index.js
│ │ └── parse.js
│ ├── config/
│ │ ├── command.js
│ │ ├── defaults.js
│ │ ├── exec.js
│ │ ├── index.js
│ │ └── load.js
│ ├── help/
│ │ └── index.js
│ ├── index.js
│ ├── monitor/
│ │ ├── index.js
│ │ ├── match.js
│ │ ├── run.js
│ │ ├── signals.js
│ │ └── watch.js
│ ├── nodemon.js
│ ├── rules/
│ │ ├── add.js
│ │ ├── index.js
│ │ └── parse.js
│ ├── spawn.js
│ ├── utils/
│ │ ├── bus.js
│ │ ├── clone.js
│ │ ├── colour.js
│ │ ├── index.js
│ │ ├── log.js
│ │ └── merge.js
│ └── version.js
├── package.json
├── test/
│ ├── cli/
│ │ ├── exec.test.js
│ │ └── parse.test.js
│ ├── config/
│ │ ├── env.test.js
│ │ ├── load-logging.test.js
│ │ └── load.test.js
│ ├── docker.sh
│ ├── events/
│ │ ├── complete.test.js
│ │ └── scripts.test.js
│ ├── fixtures/
│ │ ├── .dotfile
│ │ ├── .dotfolder/
│ │ │ ├── .nested_dotfile.js
│ │ │ ├── second.js
│ │ │ └── some_file.js
│ │ ├── 1246/
│ │ │ ├── app/
│ │ │ │ └── index.js
│ │ │ └── watching/
│ │ │ └── index.js
│ │ ├── app with spaces.js
│ │ ├── app.coffee
│ │ ├── app.js
│ │ ├── comments
│ │ ├── configs/
│ │ │ ├── public-star.json
│ │ │ ├── top-level.json
│ │ │ ├── watch-options.json
│ │ │ ├── watch-relative-filter.json
│ │ │ └── watch-relative.json
│ │ ├── default
│ │ ├── default.json
│ │ ├── env.js
│ │ ├── events/
│ │ │ ├── env.js
│ │ │ └── nodemon.json
│ │ ├── global/
│ │ │ └── nodemon.json
│ │ ├── hello.ls
│ │ ├── hello.py
│ │ ├── help.txt
│ │ ├── legacy/
│ │ │ └── .nodemonignore
│ │ ├── log.coffee
│ │ ├── nodemon.json
│ │ ├── package.json
│ │ ├── packages/
│ │ │ ├── browserify/
│ │ │ │ └── package.json
│ │ │ ├── express4/
│ │ │ │ └── package.json
│ │ │ ├── main-and-index/
│ │ │ │ ├── index.js
│ │ │ │ ├── package.json
│ │ │ │ └── server.js
│ │ │ ├── main-and-start/
│ │ │ │ ├── index.js
│ │ │ │ └── package.json
│ │ │ ├── nodemon-settings-and-package-json-settings/
│ │ │ │ ├── nodemon.json
│ │ │ │ └── package.json
│ │ │ ├── package-json-settings/
│ │ │ │ └── package.json
│ │ │ ├── start/
│ │ │ │ └── package.json
│ │ │ ├── start-and-package-json-settings/
│ │ │ │ └── package.json
│ │ │ ├── start-and-settings/
│ │ │ │ ├── nodemon.json
│ │ │ │ └── package.json
│ │ │ └── start-ignored/
│ │ │ └── package.json
│ │ ├── regexp
│ │ ├── repl.js
│ │ ├── sigint.js
│ │ ├── simple
│ │ ├── simple.json
│ │ ├── super-legacy/
│ │ │ └── nodemon-ignore
│ │ └── watch-count/
│ │ ├── index.js
│ │ └── lib/
│ │ ├── 1.js
│ │ ├── 2.js
│ │ ├── 3.js
│ │ ├── 4.js
│ │ └── 5.js
│ ├── fork/
│ │ ├── change-detect.test.js
│ │ ├── config.test.js
│ │ ├── run-mac-only.test.js
│ │ ├── run.test.js
│ │ └── watch-restart.test.js
│ ├── help/
│ │ └── help.test.js
│ ├── lib/
│ │ ├── events.test.js
│ │ ├── require-restartable.test.js
│ │ └── require.test.js
│ ├── misc/
│ │ ├── listeners.test.js
│ │ └── sigint.test.js
│ ├── mocha.opts
│ ├── monitor/
│ │ ├── count.test.js
│ │ ├── ignore.test.js
│ │ ├── match.test.js
│ │ ├── run.test.js
│ │ ├── watch-restart.test.js
│ │ └── watch.test.js
│ ├── rules/
│ │ └── index.test.js
│ ├── utils/
│ │ ├── colour.test.js
│ │ ├── log.test.js
│ │ ├── merge.test.js
│ │ └── stringify.test.js
│ └── utils.js
└── website/
├── index.html
├── oc.jq
├── oc.js
└── style.css
================================================
FILE CONTENTS
================================================
================================================
FILE: .eslintrc.json
================================================
{
"env": {
"browser": true,
"commonjs": true,
"es2021": true
},
"parserOptions": {
"ecmaVersion": 12
},
"rules": {
"space-before-function-paren": [
2,
{
"anonymous": "ignore",
"named": "never"
}
]
}
}
================================================
FILE: .github/CONTRIBUTING.md
================================================
# Contributing
## Commit messages
Commit messages must follow the [Angular-style](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits) commit format (but excluding the scope).
i.e:
```text
fix: minified scripts being removed
Also includes tests
```
This will allow for the automatic changelog to generate correctly.
## Code standards
Ensure that your code adheres to the included `.jshintrc` and `.eslintrc.json` configs.
## Sending pull requests
- new command line options are generally discouraged unless there's a *really* good reason
- add tests for newly added code (and try to mirror directory and file structure if possible)
- spell check
- PRs will not be code reviewed unless all tests are passing
*Important:* when fixing a bug, please commit a **failing test** first so that Travis CI (or I can) can show the code failing. Once that commit is in place, then commit the bug fix, so that we can test *before* and *after*.
Remember that you're developing for multiple platforms and versions of node, so if the tests pass on your Mac or Linux or Windows machine, it *may* not pass elsewhere. I personally have Mac and Linux coverage, I need help with Windows tests.
## Issues
- Please include the output from `nodemon --dump` for diagnosis
- If there's a script that nodemon is having trouble with or is causing nodemon to throw exceptions, please include it in your filed issue to allow me to replicate the issue.
================================================
FILE: .github/FUNDING.yml
================================================
github: [remy]
open_collective: nodemon
================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.md
================================================
---
name: Bug report
about: Create a report to help nodemon improve
title: ''
labels: ''
assignees: ''
---
<!--
when raising an issue please include replies to the following questions,
and if you're reporting a bug, please include details on how to replicate
and **assume** I have no knowledge of how your systems work - that includes
gulp, grunt, webpack, etc. Thank you so much <3
-->
- Versions: <!-- run this: node -e 'console.log(`node@${process.version}, ${process.platform}@${require("os").release()}`)' -->
- `nodemon -v`:
- Operating system/terminal environment (powershell, gitshell, etc):
- Using Docker? What image:
- Command you ran:
### Expected behaviour
### Actual behaviour
### Steps to reproduce
---
If applicable, please append the `--dump` flag on your command and include the output here **ensuring to remove any sensitive/personal details or tokens**.
================================================
FILE: .github/ISSUE_TEMPLATE.md
================================================
<!--
when raising an issue please include replies to the following questions,
and if you're reporting a bug, please include details on how to replicate
and **assume** I have no knowledge of how your systems work - that includes
gulp, grunt, webpack, etc. Thank you so much <3
-->
- `nodemon -v`:
- `node -v`:
- Operating system/terminal environment:
- Using Docker? What image:
- Command you ran:
### Expected behaviour
### Actual behaviour
### Steps to reproduce
---
If applicable, please append the `--dump` flag on your command and include the output here **ensuring to remove any sensitive/personal details or tokens**.
================================================
FILE: .github/no-response.yml
================================================
# Configuration for probot-no-response - https://github.com/probot/no-response
# Number of days of inactivity before an Issue is closed for lack of response
daysUntilClose: 7
# Label requiring a response
responseRequiredLabel: "needs more info"
# Comment to post when closing an Issue for lack of response. Set to `false` to disable
closeComment: >
This issue has been automatically closed because there hasn't been a response
to my request for more information from the original author. With only the
information that is currently in the issue, I don't have enough information
to take action, sorry! Please comment on this issue if you have or find the
answers we need so that someone can investigate further.
================================================
FILE: .github/oliver.yml
================================================
# Number of days the issue was closed in before the bot should reply.
# If the issue was closed in more days than this, the bot won't reply.
# Use `daysClosedIn: false` to *always* reply.
daysClosedIn: 100
# Labels to look for on issues the bot can reply to
labels:
- bug
# Comment to post when replying
comment: >
Thanks for raising this issue, and hopefully you're happy with @remy's fix. If you'd like to support this project, you can do just that through the open collective https://opencollective.com/nodemon/donate or at the very least, starring this project would give me @remy a little smile ❤️
================================================
FILE: .github/workflows/commits.yml
================================================
name: Conventional Commit Checker
on:
pull_request:
branches: [main]
types: [opened, edited, synchronize]
jobs:
check-for-cc:
runs-on: ubuntu-latest
steps:
- name: check-for-cc
id: check-for-cc
uses: agenthunt/conventional-commit-checker-action@v1.0.0
================================================
FILE: .github/workflows/node.js.yml
================================================
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
cache: npm
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
================================================
FILE: .github/workflows/release.yml
================================================
name: Release
on:
workflow_run:
workflows: ["tests"]
branches: [main]
types:
- completed
jobs:
release:
name: Release
runs-on: ubuntu-latest
# This line ensures the release ONLY runs if the 'tests' workflow passed
if: ${{ github.event.workflow_run.conclusion == 'success' }}
permissions:
contents: write
id-token: write
issues: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: npm
node-version: 24
- name: Install dependencies
run: npm ci
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# will now use the OIDC token automatically
run: npx semantic-release
================================================
FILE: .github/workflows/stale.yml
================================================
name: Mark stale issues and pull requests
on:
schedule:
- cron: "0 * * * *"
jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-stale: 14
days-before-close: 30
days-before-pr-close: -1
stale-issue-label: 'stale'
stale-pr-label: 'stale'
stale-issue-message: >
This issue has been automatically marked as idle and stale because it hasn't
had any recent activity. It will be automtically closed if no further activity
occurs. If you think this is wrong, or the problem still persists, just pop
a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3
close-issue-message: 'Automatically closing this issue due to lack of activity'
exempt-issue-labels: not-stale,security,pinned
================================================
FILE: .github/workflows/website.yml
================================================
name: website
on:
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write
env:
NETLIFY: ${{ secrets.NETLIFY }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
- run: npm ci
- run: node website/oc.js
- name: Stage changes
run: git add README.md website/index.html
- name: Commit changes
id: commit
run: |
if git diff --cached --quiet; then
echo "committed=false" >> "$GITHUB_OUTPUT"
exit 0
fi
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git commit -m "chore: website" -m "[skip ci]"
echo "committed=true" >> "$GITHUB_OUTPUT"
- name: Push changes
if: steps.commit.outputs.committed == 'true'
run: git push origin HEAD
- name: Trigger Netlify
if: env.NETLIFY != ''
run: curl -X POST "$NETLIFY"
================================================
FILE: .gitignore
================================================
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz
.env
.vscode/
pids
logs
results
npm-debug.log
node_modules
coverage
tmp
issues/
test/fixtures/test*
.idea
================================================
FILE: .jshintrc
================================================
{
"browser": true,
"camelcase": true,
"curly": true,
"devel": true,
"eqeqeq": true,
"forin": true,
"indent": 2,
"noarg": true,
"node": true,
"quotmark": "single",
"undef": true,
"strict": false,
"unused": true
}
================================================
FILE: .npmignore
================================================
test/
tmp/
coverage/
issues/
.github/
website/
*.md
Dockerfile
.eslintrc.json
.jshintrc
.releaserc
.travis.yml
commitlint.config.js
================================================
FILE: .npmrc
================================================
package-lock=true
================================================
FILE: .prettierrc.json
================================================
{
"singleQuote": true
}
================================================
FILE: .releaserc
================================================
{
"branches": ["main"]
}
================================================
FILE: .travis.yml
================================================
language: node_js
cache:
directories:
- ~/.npm
notifications:
email: false
node_js:
- '14'
- '12'
- '10'
before_install:
- if [ "$TRAVIS_PULL_REQUEST_BRANCH" == "" ]; then echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" >> .npmrc; fi
after_success:
- npm run semantic-release
branches:
except:
- /^v\d+\.\d+\.\d+$/
================================================
FILE: CODE_OF_CONDUCT.md
================================================
# Contributor Code of Conduct
As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing other's private information, such as physical or electronic addresses, without explicit permission
* Other unethical or unprofessional conduct.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
================================================
FILE: Dockerfile
================================================
#
# Ubuntu Node.js Dockerfile
#
# https://github.com/dockerfile/ubuntu/blob/master/Dockerfile
# https://docs.docker.com/examples/nodejs_web_app/
#
# Pull base image.
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y curl locales && rm -rf /var/lib/apt/lists/* \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LANG en_US.utf8
# Install Node.js
RUN curl --silent --location https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install --yes nodejs build-essential
# Install app dependencies
RUN npm install -g npx
# Bundle app source
# Trouble with COPY http://stackoverflow.com/a/30405787/2926832
# COPY . /src
WORKDIR /src
# Binds to port 8080
# EXPOSE 8080
# Defines your runtime(define default command)
# These commands unlike RUN (they are carried out in the construction of the container) are run when the container
#CMD ["node", "/src/http.js"]
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2010 - present, Remy Sharp, https://remysharp.com <remy@remysharp.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
<p align="center">
<a href="https://nodemon.io/"><img src="https://user-images.githubusercontent.com/13700/35731649-652807e8-080e-11e8-88fd-1b2f6d553b2d.png" alt="Nodemon Logo"></a>
</p>
# nodemon
nodemon is a tool that helps develop Node.js based applications by automatically restarting the node application when file changes in the directory are detected.
nodemon does **not** require *any* additional changes to your code or method of development. nodemon is a replacement wrapper for `node`. To use `nodemon`, replace the word `node` on the command line when executing your script.
[](https://npmjs.org/package/nodemon)
[](#backers) [](#sponsors)
# Installation
Either through cloning with git or by using [npm](http://npmjs.org) (the recommended way):
```bash
npm install -g nodemon # or using yarn: yarn global add nodemon
```
And nodemon will be installed globally to your system path.
You can also install nodemon as a development dependency:
```bash
npm install --save-dev nodemon # or using yarn: yarn add nodemon -D
```
With a local installation, nodemon will not be available in your system path or you can't use it directly from the command line. Instead, the local installation of nodemon can be run by calling it from within an npm script (such as `npm start`) or using `npx nodemon`.
# Usage
nodemon wraps your application, so you can pass all the arguments you would normally pass to your app:
```bash
nodemon [your node app]
```
For CLI options, use the `-h` (or `--help`) argument:
```bash
nodemon -h
```
Using nodemon is simple, if my application accepted a host and port as the arguments, I would start it as so:
```bash
nodemon ./server.js localhost 8080
```
Any output from this script is prefixed with `[nodemon]`, otherwise all output from your application, errors included, will be echoed out as expected.
You can also pass the `inspect` flag to node through the command line as you would normally:
```bash
nodemon --inspect ./server.js 80
```
If you have a `package.json` file for your app, you can omit the main script entirely and nodemon will read the `package.json` for the `main` property and use that value as the app ([ref](https://github.com/remy/nodemon/issues/14)).
nodemon will also search for the `scripts.start` property in `package.json` (as of nodemon 1.1.x).
Also check out the [FAQ](https://github.com/remy/nodemon/blob/master/faq.md) or [issues](https://github.com/remy/nodemon/issues) for nodemon.
## Automatic re-running
nodemon was originally written to restart hanging processes such as web servers, but now supports apps that cleanly exit. If your script exits cleanly, nodemon will continue to monitor the directory (or directories) and restart the script if there are any changes.
## Manual restarting
Whilst nodemon is running, if you need to manually restart your application, instead of stopping and restart nodemon, you can type `rs` with a carriage return, and nodemon will restart your process.
## Config files
nodemon supports local and global configuration files. These are usually named `nodemon.json` and can be located in the current working directory or in your home directory. An alternative local configuration file can be specified with the `--config <file>` option.
The specificity is as follows, so that a command line argument will always override the config file settings:
- command line arguments
- local config
- global config
A config file can take any of the command line arguments as JSON key values, for example:
```json
{
"verbose": true,
"ignore": ["*.test.js", "**/fixtures/**"],
"execMap": {
"rb": "ruby",
"pde": "processing --sketch={{pwd}} --run"
}
}
```
The above `nodemon.json` file might be my global config so that I have support for ruby files and processing files, and I can run `nodemon demo.pde` and nodemon will automatically know how to run the script even though out of the box support for processing scripts.
A further example of options can be seen in [sample-nodemon.md](https://github.com/remy/nodemon/blob/master/doc/sample-nodemon.md)
### package.json
If you want to keep all your package configurations in one place, nodemon supports using `package.json` for configuration.
Specify the config in the same format as you would for a config file but under `nodemonConfig` in the `package.json` file, for example, take the following `package.json`:
```json
{
"name": "nodemon",
"homepage": "http://nodemon.io",
"...": "... other standard package.json values",
"nodemonConfig": {
"ignore": ["**/test/**", "**/docs/**"],
"delay": 2500
}
}
```
Note that if you specify a `--config` file or provide a local `nodemon.json` any `package.json` config is ignored.
*This section needs better documentation, but for now you can also see `nodemon --help config` ([also here](https://github.com/remy/nodemon/blob/master/doc/cli/config.txt))*.
## Using nodemon as a module
Please see [doc/requireable.md](doc/requireable.md)
## Using nodemon as child process
Please see [doc/events.md](doc/events.md#Using_nodemon_as_child_process)
## Running non-node scripts
nodemon can also be used to execute and monitor other programs. nodemon will read the file extension of the script being run and monitor that extension instead of `.js` if there's no `nodemon.json`:
```bash
nodemon --exec "python -v" ./app.py
```
Now nodemon will run `app.py` with python in verbose mode (note that if you're not passing args to the exec program, you don't need the quotes), and look for new or modified files with the `.py` extension.
### Default executables
Using the `nodemon.json` config file, you can define your own default executables using the `execMap` property. This is particularly useful if you're working with a language that isn't supported by default by nodemon.
To add support for nodemon to know about the `.pl` extension (for Perl), the `nodemon.json` file would add:
```json
{
"execMap": {
"pl": "perl"
}
}
```
Now running the following, nodemon will know to use `perl` as the executable:
```bash
nodemon script.pl
```
It's generally recommended to use the global `nodemon.json` to add your own `execMap` options. However, if there's a common default that's missing, this can be merged in to the project so that nodemon supports it by default, by changing [default.js](https://github.com/remy/nodemon/blob/master/lib/config/defaults.js) and sending a pull request.
## Monitoring multiple directories
By default nodemon monitors the current working directory. If you want to take control of that option, use the `--watch` option to add specific paths:
```bash
nodemon --watch app --watch libs app/server.js
```
Now nodemon will only restart if there are changes in the `./app` or `./libs` directory. By default nodemon will traverse sub-directories, so there's no need in explicitly including sub-directories.
Nodemon also supports unix globbing, e.g `--watch './lib/*'`. The globbing pattern must be quoted. For advanced globbing, [see `picomatch` documentation](https://github.com/micromatch/picomatch#advanced-globbing), the library that nodemon uses through `chokidar` (which in turn uses it through `anymatch`).
## Specifying extension watch list
By default, nodemon looks for files with the `.js`, `.mjs`, `.coffee`, `.litcoffee`, and `.json` extensions. If you use the `--exec` option and monitor `app.py` nodemon will monitor files with the extension of `.py`. However, you can specify your own list with the `-e` (or `--ext`) switch like so:
```bash
nodemon -e js,pug
```
Now nodemon will restart on any changes to files in the directory (or subdirectories) with the extensions `.js`, `.pug`.
## Ignoring files
By default, nodemon will only restart when a `.js` JavaScript file changes. In some cases you will want to ignore some specific files, directories or file patterns, to prevent nodemon from prematurely restarting your application.
This can be done via the command line:
```bash
nodemon --ignore lib/ --ignore tests/
```
Or specific files can be ignored:
```bash
nodemon --ignore lib/app.js
```
Patterns can also be ignored (but be sure to quote the arguments):
```bash
nodemon --ignore 'lib/*.js'
```
**Important** the ignore rules are patterns matched to the full absolute path, and this determines how many files are monitored. If using a wild card glob pattern, it needs to be used as `**` or omitted entirely. For example, `nodemon --ignore '**/test/**'` will work, whereas `--ignore '*/test/*'` will not.
Note that by default, nodemon will ignore the `.git`, `node_modules`, `bower_components`, `.nyc_output`, `coverage` and `.sass-cache` directories and *add* your ignored patterns to the list. If you want to indeed watch a directory like `node_modules`, you need to [override the underlying default ignore rules](https://github.com/remy/nodemon/blob/master/faq.md#overriding-the-underlying-default-ignore-rules).
## Application isn't restarting
In some networked environments (such as a container running nodemon reading across a mounted drive), you will need to use the `legacyWatch: true` which enables Chokidar's polling.
Via the CLI, use either `--legacy-watch` or `-L` for short:
```bash
nodemon -L
```
Though this should be a last resort as it will poll every file it can find.
## Delaying restarting
In some situations, you may want to wait until a number of files have changed. The timeout before checking for new file changes is 1 second. If you're uploading a number of files and it's taking some number of seconds, this could cause your app to restart multiple times unnecessarily.
To add an extra throttle, or delay restarting, use the `--delay` command:
```bash
nodemon --delay 10 server.js
```
For more precision, milliseconds can be specified. Either as a float:
```bash
nodemon --delay 2.5 server.js
```
Or using the time specifier (ms):
```bash
nodemon --delay 2500ms server.js
```
The delay figure is number of seconds (or milliseconds, if specified) to delay before restarting. So nodemon will only restart your app the given number of seconds after the *last* file change.
If you are setting this value in `nodemon.json`, the value will always be interpreted in milliseconds. E.g., the following are equivalent:
```bash
nodemon --delay 2.5
{
"delay": 2500
}
```
## Gracefully reloading down your script
It is possible to have nodemon send any signal that you specify to your application.
```bash
nodemon --signal SIGHUP server.js
```
Your application can handle the signal as follows.
```js
process.on("SIGHUP", function () {
reloadSomeConfiguration();
process.kill(process.pid, "SIGTERM");
})
```
Please note that nodemon will send this signal to every process in the process tree.
If you are using `cluster`, then each workers (as well as the master) will receive the signal. If you wish to terminate all workers on receiving a `SIGHUP`, a common pattern is to catch the `SIGHUP` in the master, and forward `SIGTERM` to all workers, while ensuring that all workers ignore `SIGHUP`.
```js
if (cluster.isMaster) {
process.on("SIGHUP", function () {
for (const worker of Object.values(cluster.workers)) {
worker.process.kill("SIGTERM");
}
});
} else {
process.on("SIGHUP", function() {})
}
```
## Controlling shutdown of your script
nodemon sends a kill signal to your application when it sees a file update. If you need to clean up on shutdown inside your script you can capture the kill signal and handle it yourself.
The following example will listen once for the `SIGUSR2` signal (used by nodemon to restart), run the clean up process and then kill itself for nodemon to continue control:
```js
// important to use `on` and not `once` as nodemon can re-send the kill signal
process.on('SIGUSR2', function () {
gracefulShutdown(function () {
process.kill(process.pid, 'SIGTERM');
});
});
```
Note that the `process.kill` is *only* called once your shutdown jobs are complete. Hat tip to [Benjie Gillam](http://www.benjiegillam.com/2011/08/node-js-clean-restart-and-faster-development-with-nodemon/) for writing this technique up.
## Triggering events when nodemon state changes
If you want growl like notifications when nodemon restarts or to trigger an action when an event happens, then you can either `require` nodemon or add event actions to your `nodemon.json` file.
For example, to trigger a notification on a Mac when nodemon restarts, `nodemon.json` looks like this:
```json
{
"events": {
"restart": "osascript -e 'display notification \"app restarted\" with title \"nodemon\"'"
}
}
```
A full list of available events is listed on the [event states wiki](https://github.com/remy/nodemon/wiki/Events#states). Note that you can bind to both states and messages.
## Pipe output to somewhere else
```js
nodemon({
script: ...,
stdout: false // important: this tells nodemon not to output to console
}).on('readable', function() { // the `readable` event indicates that data is ready to pick up
this.stdout.pipe(fs.createWriteStream('output.txt'));
this.stderr.pipe(fs.createWriteStream('err.txt'));
});
```
## Using nodemon in your gulp workflow
Check out the [gulp-nodemon](https://github.com/JacksonGariety/gulp-nodemon) plugin to integrate nodemon with the rest of your project's gulp workflow.
## Using nodemon in your Grunt workflow
Check out the [grunt-nodemon](https://github.com/ChrisWren/grunt-nodemon) plugin to integrate nodemon with the rest of your project's grunt workflow.
## Pronunciation
> nodemon, is it pronounced: node-mon, no-demon or node-e-mon (like pokémon)?
Well...I've been asked this many times before. I like that I've been asked this before. There's been bets as to which one it actually is.
The answer is simple, but possibly frustrating. I'm not saying (how I pronounce it). It's up to you to call it as you like. All answers are correct :)
## Design principles
- Fewer flags is better
- Works across all platforms
- Fewer features
- Let individuals build on top of nodemon
- Offer all CLI functionality as an API
- Contributions must have and pass tests
Nodemon is not perfect, and CLI arguments has sprawled beyond where I'm completely happy, but perhaps it can be reduced a little one day.
## FAQ
See the [FAQ](https://github.com/remy/nodemon/blob/master/faq.md) and please add your own questions if you think they would help others.
## Backers
Thank you to all [our backers](https://opencollective.com/nodemon#backer)! 🙏
[](https://opencollective.com/nodemon#backers)
## Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Sponsor this project today ❤️](https://opencollective.com/nodemon#sponsor)
<div style="overflow: hidden; margin-bottom: 80px;"><!--oc--><a title='Netpositive' data-id='162674' data-tier='1' href='https://najlepsibukmacherzy.pl/ranking-legalnych-bukmacherow/'><img alt='Netpositive' src='https://opencollective-production.s3.us-west-1.amazonaws.com/52acecf0-608a-11eb-b17f-5bca7c67fe7b.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Best online casinos not on GamStop in the UK' data-id='243140' data-tier='1' href='https://casino-wise.com/'><img alt='Best online casinos not on GamStop in the UK' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/f889d209-a931-4c06-a529-fe1f86c411bf/casino-wise-logo.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='TheCasinoDB' data-id='270835' data-tier='1' href='https://www.thecasinodb.com'><img alt='TheCasinoDB' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/7fbc2acb-ba5c-4a5c-99d2-17e205e9a151/8a0f6204-f303-4129-a498-2263fd21e640.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Goread.io' data-id='320564' data-tier='1' href='https://goread.io/buy-instagram-followers'><img alt='Goread.io' src='https://opencollective-production.s3.us-west-1.amazonaws.com/7d1302a0-0f33-11ed-a094-3dca78aec7cd.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Best Australian online casinos. Reviewed by Correct Casinos.' data-id='322445' data-tier='1' href='https://www.correctcasinos.com/australian-online-casinos/'><img alt='Best Australian online casinos. Reviewed by Correct Casinos.' src='https://opencollective-production.s3.us-west-1.amazonaws.com/fef95200-1551-11ed-ba3f-410c614877c8.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='nongamstopcasinos.net' data-id='367236' data-tier='1' href='https://www.pieria.co.uk/'><img alt='nongamstopcasinos.net' src='https://opencollective-production.s3.us-west-1.amazonaws.com/fb8b5ba0-3904-11ed-8516-edd7b7687a36.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Buy Instagram Likes' data-id='411448' data-tier='1' href='https://poprey.com/'><img alt='Buy Instagram Likes' src='https://opencollective-production.s3.us-west-1.amazonaws.com/fe650970-c21c-11ec-a499-b55e54a794b4.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='OnlineCasinosSpelen' data-id='423738' data-tier='1' href='https://onlinecasinosspelen.com'><img alt='OnlineCasinosSpelen' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/47e87426-6a55-4f69-9fb5-4e5032dc35a8/5d10dd22-320e-47d4-84e6-d144874f1f5f.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Beoordelen van nieuwe online casino's 2023' data-id='424449' data-tier='1' href='https://Nieuwe-Casinos.net'><img alt='Beoordelen van nieuwe online casino's 2023' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/b803f279-c2a2-42da-8f05-d23e73cb8b26/aba64d6d-97e8-468c-b598-db08e0a134c5.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Buy real Instagram followers from Twicsy starting at only $2.97. Twicsy has been voted the best site to buy followers from the likes of US Magazine.' data-id='453050' data-tier='1' href='https://twicsy.com/buy-instagram-followers'><img alt='Buy real Instagram followers from Twicsy starting at only $2.97. Twicsy has been voted the best site to buy followers from the likes of US Magazine.' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/f07b6f83-d0ed-43c6-91ae-ec8fa90512cd/twicsy-followers.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='SocialWick offers the best Instagram Followers in the market. If you are looking to boost your organic growth, buy Instagram followers from SocialWick' data-id='462750' data-tier='1' href='https://www.socialwick.com/instagram/followers'><img alt='SocialWick offers the best Instagram Followers in the market. If you are looking to boost your organic growth, buy Instagram followers from SocialWick' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/4a977a23-f63a-489a-891b-c0eb8cab1cb4/icon.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Buy Telegram Members' data-id='501897' data-tier='1' href='https://buycheapestfollowers.com/buy-telegram-channel-members'><img alt='Buy Telegram Members' src='https://github-production-user-asset-6210df.s3.amazonaws.com/13700/286696172-747dca05-a1e8-4d93-a9e9-95054d1566df.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='We review the entire iGaming industry from A to Z' data-id='504258' data-tier='1' href='https://casinolandia.com'><img alt='We review the entire iGaming industry from A to Z' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/5f858add-77f1-47a2-b577-39eecb299c8c/Logo264.jpg' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='CryptoCasinos.online' data-id='525119' data-tier='1' href='https://cryptocasinos.online/'><img alt='CryptoCasinos.online' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/97712948-3b1b-4026-a109-257d879baa23/CryptoCasinos.Online-FBcover18.jpg' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='No deposit casino promo Codes 2024 - The best online Casinos websites. No deposit bonus codes, Free Spins and Promo Codes. Stake, Roobet, Jackpotcity and more.' data-id='540890' data-tier='1' href='https://www.ownedcore.com/casino'><img alt='No deposit casino promo Codes 2024 - The best online Casinos websites. No deposit bonus codes, Free Spins and Promo Codes. Stake, Roobet, Jackpotcity and more.' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/8bd4b78c-95e2-4c41-b4f4-d7fd6c0e12cd/logo4-e6140c27.webp' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Online casino.' data-id='541128' data-tier='1' href='https://www.fruityking.co.nz'><img alt='Online casino.' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/7cde3c6f-052c-41bb-93f0-8be187682791/10e42029-c513-4edd-ac24-a8e41d697a96.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Boost your social media presence effortlessly with top-quality Instagram and TikTok followers and likes.' data-id='579911' data-tier='1' href='https://leofame.com/buy-instagram-followers'><img alt='Boost your social media presence effortlessly with top-quality Instagram and TikTok followers and likes.' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/186c0e19-b195-4228-901a-ab1b70d63ee5/WhatsApp%20Image%202024-06-21%20at%203.50.43%20AM.jpg' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Social Media Management and all kinds of followers' data-id='587050' data-tier='1' href='https://www.socialfollowers.uk/buy-tiktok-followers/'><img alt='Social Media Management and all kinds of followers' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/8941f043-5d00-4e33-a1fd-f2d27ca54963/Social%20Followers%20Uk%20logo%20black.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Betwinner is an online bookmaker offering sports betting, casino games, and more.' data-id='594768' data-tier='1' href='https://guidebook.betwinner.com/'><img alt='Betwinner is an online bookmaker offering sports betting, casino games, and more.' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/82cab29a-7002-4924-83bf-2eecb03d07c4/0x0.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='At Buzzoid, you can buy Instagram followers quickly, safely, and easily with just a few clicks. Rated world's #1 IG service since 2012.' data-id='602382' data-tier='1' href='https://buzzoid.com/buy-instagram-followers/'><img alt='At Buzzoid, you can buy Instagram followers quickly, safely, and easily with just a few clicks. Rated world's #1 IG service since 2012.' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/f77464f7-0457-451a-b29d-8e3b161ce83f/285fbc9f-6461-4393-8942-da62d1bed968.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Zamsino.com' data-id='608094' data-tier='1' href='https://zamsino.com/'><img alt='Zamsino.com' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/e3e99af5-a024-4d85-8594-8fd22e506bc9/Zamsino.com%20Logo.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Reviewing and comparing online casinos available to Finnish players. In addition, we publish relevant news and blog posts about the world of iGaming.' data-id='620398' data-tier='1' href='https://uusimmatkasinot.com/'><img alt='Reviewing and comparing online casinos available to Finnish players. In addition, we publish relevant news and blog posts about the world of iGaming.' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/d5326d0f-3cde-41f4-b480-78ef8a2fb015/Uusimmatkasinot_head_siteicon.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Buzzvoice is your one-stop shop for all your social media marketing needs. With Buzzvoice, you can buy followers, comments, likes, video views and more!' data-id='646075' data-tier='1' href='https://buzzvoice.com/'><img alt='Buzzvoice is your one-stop shop for all your social media marketing needs. With Buzzvoice, you can buy followers, comments, likes, video views and more!' src='https://opencollective-production.s3.us-west-1.amazonaws.com/acd68da0-e71e-11ec-a84e-fd82f80383c1.jpg' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='' data-id='648524' data-tier='1' href='https://www.c19.cl/'><img alt='' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/01b96d4c-4852-4499-8c70-e3ec57d0c58c/2024-05-09_17-27%20(1).png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='SocialBoosting: Buy Instagram & TikTok Followers, Likes, Views' data-id='653711' data-tier='1' href='https://www.socialboosting.com/'><img alt='SocialBoosting: Buy Instagram & TikTok Followers, Likes, Views' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/80a54dfd-8952-4851-8cab-dcfa4a8a0a87/favicon.gif' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Ігрові автомати онлайн' data-id='655295' data-tier='1' href='https://casino.ua/casino/slots/'><img alt='Ігрові автомати онлайн' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/3c8fa725-e203-4c57-933c-0a884527fd5b/images.jpg' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Kasinohai.com' data-id='673849' data-tier='1' href='https://www.kasinohai.com/nettikasinot'><img alt='Kasinohai.com' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/ad75f68f-cb97-46f8-8981-bbe81ad6ffc9/51bafb1d-ed66-482f-8a8e-9b7b07d55f96.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Casino Online Chile' data-id='678929' data-tier='1' href='https://www.acee.cl/'><img alt='Casino Online Chile' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/292c66d6-0c5c-40e8-96f0-900dcdeaaf47/acee-casino-chile.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='casino online chile' data-id='709152' data-tier='1' href='https://chilecasinoonline.cl/'><img alt='casino online chile' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/7f3780b2-b7a7-47aa-9837-c01099585495/casino-online-chile-logo.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Vanguard Media évalue les casinos en ligne pour joueurs français, testant les sites en France. Nos classements stricts garantissent des casinos fiables et sûrs.' data-id='723517' data-tier='1' href='https://www.vanguardngr.com/casino/fr/'><img alt='Vanguard Media évalue les casinos en ligne pour joueurs français, testant les sites en France. Nos classements stricts garantissent des casinos fiables et sûrs.' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/38065879-ef15-4e67-80a1-bdbb30ecb485/101895f1-ca10-49e3-a297-23a915fb9524.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Bei Releaf erhalten Sie schnell und diskret Ihr Cannabis Rezept online. Unsere Ärzte prüfen Ihre Angaben und stellen bei Eignung das Rezept aus. Anschließend können Sie legal und sicher medizinisches Cannabis über unsere Partnerapotheken kaufen.' data-id='727109' data-tier='1' href='https://releaf.com/de'><img alt='Bei Releaf erhalten Sie schnell und diskret Ihr Cannabis Rezept online. Unsere Ärzte prüfen Ihre Angaben und stellen bei Eignung das Rezept aus. Anschließend können Sie legal und sicher medizinisches Cannabis über unsere Partnerapotheken kaufen.' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/b686d646-5029-4b4c-8cab-9645ab2679de/9da596d1-f48a-41ec-947d-a64dd8e7529c.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Download multithreaded HEIC to JPG converter software for Windows 10/11' data-id='751387' data-tier='1' href='https://www.softorbits.net/convert-heic-to-jpeg/'><img alt='Download multithreaded HEIC to JPG converter software for Windows 10/11' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/34c7f097-4c59-4be6-a59c-55af13b0bd10/logo-final-square512.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='We specialize in the online gambling industry, helping players access reliable and verified information about the best online casinos and pokies in Australia. Our team tests casinos and games, collects user reviews from Trustpilot, and organizes them in o' data-id='753333' data-tier='1' href='https://au.trustpilot.com/review/bestpayidpokies.net'><img alt='We specialize in the online gambling industry, helping players access reliable and verified information about the best online casinos and pokies in Australia. Our team tests casinos and games, collects user reviews from Trustpilot, and organizes them in o' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/985a0ae7-54c3-4680-8816-bc8d656f7562/payidpokies.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Wolf Winner Casino' data-id='754359' data-tier='1' href='https://www.wolfwinner.fun/en'><img alt='Wolf Winner Casino' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/556e09fb-d232-4c99-9644-9d28e1cfe27b/wolf-winner-casino-logo.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='AUCrazyVegas' data-id='756605' data-tier='1' href='https://au.crazyvegas.com/'><img alt='AUCrazyVegas' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/be59e9fa-a83d-4244-9e74-f54b7f454e14/au.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='iDealeCasinos' data-id='757116' data-tier='1' href='https://idealecasinos.com/'><img alt='iDealeCasinos' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/907841d3-435e-44b4-9684-c33fd8635ece/ideale-casinos-square-white-logo-300.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='' data-id='757154' data-tier='1' href='https://nl.trustpilot.com/review/buitenlandsecasino.vip'><img alt='' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/9465308a-8e44-4606-af5d-5a81a3c6567b/ChatGPT%20Image%20Nov%2015%2C%202025%2C%2002_53_25%20PM.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='BetPokies.co.nz is your New Zealand guide in the world of online gambling. Our site was created by gamblers for gamblers.' data-id='760968' data-tier='1' href='https://nz.trustpilot.com/review/betpokies.co.nz'><img alt='BetPokies.co.nz is your New Zealand guide in the world of online gambling. Our site was created by gamblers for gamblers.' src='https://opencollective-production.s3.us-west-1.amazonaws.com/117c78d0-973e-11ed-b663-5b4207ae3c06.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='one x bet - Arabic betting site' data-id='765806' data-tier='1' href='https://xn----ymcbek6cvgvaq.com/'><img alt='one x bet - Arabic betting site' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/529647a4-6230-4013-bcc5-b5855158c022/ChatGPT%20Image%20Sep%2030%2C%202025%2C%2001_29_18%20PM.jpg' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Online Casino Zonder Registratie' data-id='766416' data-tier='1' href='https://nl.trustpilot.com/review/zonderregistratiecasinos.com'><img alt='Online Casino Zonder Registratie' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/cf382ddc-627b-4bd9-8870-43ee28d2a628/casino-zonder-registratie.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='We test dozens of casinos every month and select the coolest ones for Australian players. ' data-id='767300' data-tier='1' href='https://au.trustpilot.com/review/payid-casino.net'><img alt='We test dozens of casinos every month and select the coolest ones for Australian players. ' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/ecd8a5f4-fd86-4903-a512-cbfaff35e7ef/payidpokiessites.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Pokies Reviews' data-id='771618' data-tier='1' href='https://au.trustpilot.com/review/pokiesgambler.com'><img alt='Pokies Reviews' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/a04c9ed0-b1d5-4dbe-a5fd-4cec00567916/pokiesgambler.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Buy TikTok Comments' data-id='772992' data-tier='1' href='https://buylikesservices.com/buy-tiktok-custom-comments/'><img alt='Buy TikTok Comments' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/1125514e-fc5e-4e1f-a186-a478fa7c3189/6bf0e4e1-f6aa-4d00-a141-f5b2c2642d65.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Mi misión es la educación y transparencia en el mundo de los casinos online' data-id='780847' data-tier='1' href='https://www.educatransparencia.cl/'><img alt='Mi misión es la educación y transparencia en el mundo de los casinos online' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/c034fdcb-1d17-4c83-8105-f3cfa4f874d6/educalogocito.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Spreading knowledge about $ETH' data-id='783771' data-tier='1' href='https://theethereum.wiki'><img alt='Spreading knowledge about $ETH' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/bfce6f44-affd-4acd-94c2-bf33797f1cb2/Screenshot%202026-01-28%20at%2014.19.23.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='' data-id='783792' data-tier='1' href='https://time.now/'><img alt='' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/4cca6170-acb2-4b1a-b85b-7715416237cf/time-now-logo3.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Best online sports betting and casino company.' data-id='784673' data-tier='1' href='https://global.fun88.com/'><img alt='Best online sports betting and casino company.' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/1688ebca-4984-4b9b-a24d-8fdd1233892f/fun88-logo.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='bestecasinozondercruks' data-id='785087' data-tier='1' href='https://nl.trustpilot.com/review/bestecasinozondercruks.online'><img alt='bestecasinozondercruks' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/4948eca9-abd5-49ea-bb70-1ea6053f8663/ChatGPT%20Image%20Dec%2027%2C%202025%2C%2010_22_47%20PM-min.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Best online sports betting company in Thailand.' data-id='787477' data-tier='1' href='https://www.fun88thh.com/th/'><img alt='Best online sports betting company in Thailand.' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/bbf7174c-fc01-4ce6-86b5-f621e350969d/fun88-logo.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Best online sports betting company in Vietnam.' data-id='787478' data-tier='1' href='https://www.fun88vnu.com/vn/'><img alt='Best online sports betting company in Vietnam.' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/ed704e1d-3894-48bb-83e3-6094b2c68a5c/fun88-logo.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='We testen elke maand tientallen casino’s en kiezen de beste uit voor Nederlandse spelers.' data-id='787870' data-tier='1' href='https://nl.trustpilot.com/review/scandicasinos.com'><img alt='We testen elke maand tientallen casino’s en kiezen de beste uit voor Nederlandse spelers.' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/115ec975-5575-436a-9406-9ef439dd28c0/scandicasinos.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='ThePokies Net' data-id='787930' data-tier='1' href='https://au.trustpilot.com/review/thepokies-au.com'><img alt='ThePokies Net' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/7981d14b-e79a-45a6-91b5-6040b0077e28/pokiesnet-casino.jpg' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Aviator Game Online' data-id='789860' data-tier='1' href='https://www.trustpilot.com/review/aviatorplay.top'><img alt='Aviator Game Online' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/b3cf9a31-607e-4d3f-8b86-0726f4323dae/aviatorr.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='Plinko Game' data-id='789874' data-tier='1' href='https://www.trustpilot.com/review/plinkoplay.top'><img alt='Plinko Game' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/5e953df9-1876-45b6-9ffc-f2009804935b/plinkoo.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='iDEAL Casinos' data-id='791586' data-tier='1' href='https://nl.trustpilot.com/review/idealcasinos.co.com'><img alt='iDEAL Casinos' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/974ae057-b821-4404-b0b7-c85c075996a4/Screen-Shot-2023-03-17-at-10.17.00.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a>
<a title='POLi Pay Casinos' data-id='796704' data-tier='1' href='https://nz.trustpilot.com/review/surfpokies.com'><img alt='POLi Pay Casinos' src='https://opencollective-production.s3.us-west-1.amazonaws.com/account-avatar/cd762491-d631-4fa3-a49e-bd373e6a338b/polii.png' style='object-fit: contain; float: left; margin:12px' height='120' width='120'></a><!--oc-->
</div>
Please note that links to the sponsors above are not direct endorsements nor affiliated with any of contributors of the nodemon project.
# License
MIT [http://rem.mit-license.org](http://rem.mit-license.org)
================================================
FILE: TODO.md
================================================
# TODO
A rough outline of things I'd like to do with nodemon after 13 years of supporting the software:
- Upgrade mocha (I tried Jest once, but it can't fork and monitor the outputs, which is how most of the tests run)
- Switch to prettier from jshint (and commit formatted code)
- Sweep code for unused or overly complicated code(!)
================================================
FILE: bin/nodemon.js
================================================
#!/usr/bin/env node
const cli = require('../lib/cli');
const nodemon = require('../lib/');
const options = cli.parse(process.argv);
nodemon(options);
const fs = require('fs');
// checks for available update and returns an instance
const pkg = JSON.parse(fs.readFileSync(__dirname + '/../package.json'));
if (pkg.version.indexOf('0.0.0') !== 0 && options.noUpdateNotifier !== true) {
require('simple-update-notifier')({ pkg });
}
================================================
FILE: commitlint.config.js
================================================
module.exports = {
extends: ['@commitlint/config-conventional'],
};
================================================
FILE: doc/arch.md
================================================
# nodemon code arch
```
CLI -> parser -> nodemon options -> rules
rules -> configure -> watch -> start process
```
## CLI examples
Watch src but only *.js and *.coffee
nodemon --watch src/ -e js,coffee app.js
Parsed to:
{
watch: ['src/'],
ignore: [],
script: 'app.js'
options: {
extensions: ['js', 'coffee'],
exec: 'node'
}
}
Watch with no args:
nodemon
Parsed to (assuming a package.json or index.js is found):
{
watch: [], // meaning all subdirectories
ignore: [],
script: 'index.js',
options: {
extensions: ['js'],
exec: 'node'
}
}
================================================
FILE: doc/cli/authors.txt
================================================
Remy Sharp - author and maintainer
https://github.com/remy
https://twitter.com/rem
Contributors: https://github.com/remy/nodemon/graphs/contributors ❤︎
Please help make nodemon better: https://github.com/remy/nodemon/
================================================
FILE: doc/cli/config.txt
================================================
Typically the options to control nodemon are passed in via the CLI and are
listed under: nodemon --help options
nodemon can also be configured via a local and global config file:
* $HOME/nodemon.json
* $PWD/nodemon.json OR --config <file>
* nodemonConfig in package.json
All config options in the .json file map 1-to-1 with the CLI options, so a
config could read as:
{
"ext": "*.pde",
"verbose": true,
"exec": "processing --sketch=game --run"
}
There are a limited number of variables available in the config (since you
could use backticks on the CLI to use a variable, backticks won't work in
the .json config).
* {{pwd}} - the current directory
* {{filename}} - the filename you pass to nodemon
For example:
{
"ext": "*.pde",
"verbose": true,
"exec": "processing --sketch={{pwd}} --run"
}
The global config file is useful for setting up default executables
instead of repeating the same option in each of your local configs:
{
"verbose": true,
"execMap": {
"rb": "ruby",
"pde": "processing --sketch={{pwd}} --run"
}
}
================================================
FILE: doc/cli/help.txt
================================================
Usage: nodemon [options] [script.js] [args]
Options:
--config file ............ alternate nodemon.json config file to use
-e, --ext ................ extensions to look for, ie. js,pug,hbs.
-x, --exec app ........... execute script with "app", ie. -x "python -v".
-w, --watch path ......... watch directory "path" or files. use once for
each directory or file to watch.
-i, --ignore ............. ignore specific files or directories.
-V, --verbose ............ show detail on what is causing restarts.
-- <your args> ........... to tell nodemon stop slurping arguments.
Note: if the script is omitted, nodemon will try to read "main" from
package.json and without a nodemon.json, nodemon will monitor .js, .mjs, .coffee,
.litcoffee, and .json by default.
For advanced nodemon configuration use nodemon.json: nodemon --help config
See also the sample: https://github.com/remy/nodemon/wiki/Sample-nodemon.json
Examples:
$ nodemon server.js
$ nodemon -w ../foo server.js apparg1 apparg2
$ nodemon --exec python app.py
$ nodemon --exec "make build" -e "styl hbs"
$ nodemon app.js -- --config # pass config to app.js
\x1B[1mAll options are documented under: \x1B[4mnodemon --help options\x1B[0m
================================================
FILE: doc/cli/logo.txt
================================================
; ;
kO. x0
KMX, .:x0kc. 'KMN
0MMM0: 'oKMMMMMMMXd, ;OMMMX
oMMMMMWKOONMMMMMMMMMMMMMWOOKWMMMMMx
OMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMK.
.oWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMd.
KMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN
KMMMMMMMMMMMMMMW0k0WMMMMMMMMMMMMMMW
KMMMMMMMMMMMNk:. :xNMMMMMMMMMMMW
KMMMMMMMMMMK OMMMMMMMMMMW
KMMMMMMMMMMO xMMMMMMMMMMN
KMMMMMMMMMMO xMMMMMMMMMMN
KMMMMMMMMMMO xMMMMMMMMMMN
KMMMMMMMMMMO xMMMMMMMMMMN
KMMMMMMMMMMO xMMMMMMMMMMN
KMMMMMMMMMNc ;NMMMMMMMMMN
KMMMMMW0o' .lOWMMMMMN
KMMKd; ,oKMMN
kX: ,K0
================================================
FILE: doc/cli/options.txt
================================================
Configuration
--config <file> .......... alternate nodemon.json config file to use
--exitcrash .............. exit on crash, allows nodemon to work with other watchers
-i, --ignore ............. ignore specific files or directories
--no-colors .............. disable color output
--signal <signal> ........ use specified kill signal instead of default (ex. SIGTERM)
-w, --watch path ......... watch directory "dir" or files. use once for each
directory or file to watch
--no-update-notifier ..... opt-out of update version check
Execution
-C, --on-change-only ..... execute script on change only, not startup
--cwd <dir> .............. change into <dir> before running the script
-e, --ext ................ extensions to look for, ie. "js,pug,hbs"
-I, --no-stdin ........... nodemon passes stdin directly to child process
--spawn .................. force nodemon to use spawn (over fork) [node only]
-x, --exec app ........... execute script with "app", ie. -x "python -v"
-- <your args> ........... to tell nodemon stop slurping arguments
Watching
-d, --delay n ............ debounce restart for "n" seconds
-L, --legacy-watch ....... use polling to watch for changes (typically needed
when watching over a network/Docker)
-P, --polling-interval ... combined with -L, milliseconds to poll for (default 100)
Information
--dump ................... print full debug configuration
-h, --help ............... default help
--help <topic> ........... help on a specific feature. Try "--help topics"
-q, --quiet .............. minimise nodemon messages to start/stop only
-v, --version ............ current nodemon version
-V, --verbose ............ show detail on what is causing restarts
> Note that any unrecognised arguments are passed to the executing command.
================================================
FILE: doc/cli/topics.txt
================================================
options .................. show all available nodemon options
config ................... default config options using nodemon.json
authors .................. contributors to this project
logo ..................... <3
whoami ................... I, AM, NODEMON \o/
Please support https://github.com/remy/nodemon/
================================================
FILE: doc/cli/usage.txt
================================================
Usage: nodemon [nodemon options] [script.js] [args]
See "nodemon --help" for more.
================================================
FILE: doc/cli/whoami.txt
================================================
__/\\\\\_____/\\\_______/\\\\\_______/\\\\\\\\\\\\_____/\\\\\\\\\\\\\\\__/\\\\____________/\\\\_______/\\\\\_______/\\\\\_____/\\\_
_\/\\\\\\___\/\\\_____/\\\///\\\____\/\\\////////\\\__\/\\\///////////__\/\\\\\\________/\\\\\\_____/\\\///\\\____\/\\\\\\___\/\\\_
_\/\\\/\\\__\/\\\___/\\\/__\///\\\__\/\\\______\//\\\_\/\\\_____________\/\\\//\\\____/\\\//\\\___/\\\/__\///\\\__\/\\\/\\\__\/\\\_
_\/\\\//\\\_\/\\\__/\\\______\//\\\_\/\\\_______\/\\\_\/\\\\\\\\\\\_____\/\\\\///\\\/\\\/_\/\\\__/\\\______\//\\\_\/\\\//\\\_\/\\\_
_\/\\\\//\\\\/\\\_\/\\\_______\/\\\_\/\\\_______\/\\\_\/\\\///////______\/\\\__\///\\\/___\/\\\_\/\\\_______\/\\\_\/\\\\//\\\\/\\\_
_\/\\\_\//\\\/\\\_\//\\\______/\\\__\/\\\_______\/\\\_\/\\\_____________\/\\\____\///_____\/\\\_\//\\\______/\\\__\/\\\_\//\\\/\\\_
_\/\\\__\//\\\\\\__\///\\\__/\\\____\/\\\_______/\\\__\/\\\_____________\/\\\_____________\/\\\__\///\\\__/\\\____\/\\\__\//\\\\\\_
_\/\\\___\//\\\\\____\///\\\\\/_____\/\\\\\\\\\\\\/___\/\\\\\\\\\\\\\\\_\/\\\_____________\/\\\____\///\\\\\/_____\/\\\___\//\\\\\_
_\///_____\/////_______\/////_______\////////////_____\///////////////__\///______________\///_______\/////_______\///_____\/////__
================================================
FILE: doc/events.md
================================================
# Events
nodemon will emit events based on the child process.
## Commands
- restart
- config:update
- quit
## States
- start - child process has started
- crash - child process has crashed (nodemon will not emit exit)
- exit - child process has cleanly exited (ie. no crash)
- restart([ array of files triggering the restart ]) - child process has restarted
- config:update - nodemon's config has changed
## Messages
- log({ type, message (plain text log), colour (colour coded log) }) - logging from nodemon (not the child process)
- stdout - the stdout stream from the child process
- stderr - the stderr stream from the child process
- readable - stdout and stderr streams are ready ([example](https://github.com/remy/nodemon#pipe-output-to-somewhere-else))
Note that if you want to supress the normal stdout & stderr of the child, in favour
of processing the stream manually using the stdout/stderr nodemon events, pass
nodemon the option of `stdout: false`.
## Using nodemon events
If nodemon is required, events can be bound and emitted on the nodemon object:
```js
var nodemon = require('nodemon');
nodemon({ script: 'app.js' }).on('start', function () {
console.log('nodemon started');
}).on('crash', function () {
console.log('script crashed for some reason');
});
// force a restart
nodemon.emit('restart');
// force a quit
nodemon.emit('quit');
```
## Using nodemon as child process
If nodemon is a spawned process, then the child (nodemon) will emit message
events whereby the event argument contains the event type, and instead of
emitting events, you `send` the command:
```js
// using `spawn` as example, can use other functions like `fork`, etc
// https://nodejs.org/api/child_process.html
const { spawn } = require('child_process');
function spawnNodemon() {
const cp = spawn('nodemon', ['path/to/file.js', '--watch', 'path/to/watch'], {
// the important part is the 4th option 'ipc'
// this way `process.send` will be available in the child process (nodemon)
// so it can communicate back with parent process (through `.on()`, `.send()`)
// https://nodejs.org/api/child_process.html#child_process_options_stdio
stdio: ['pipe', 'pipe', 'pipe', 'ipc'],
});
return cp;
}
var app = spawnNodemon();
app.on('message', function (event) {
if (event.type === 'start') {
console.log('nodemon started');
} else if (event.type === 'crash') {
console.log('script crashed for some reason');
}
});
// force a restart
app.send('restart');
// force a quit
app.send('quit');
```
Note that even though the child will still emit a `message` event whose type is
`exit`, it makes more sense to listen to the actual `exit` event on the child:
```js
app.on('exit', function () {
console.log('nodemon quit');
});
```
================================================
FILE: doc/option-parsing-logic.md
================================================
# Option parsing logic
1. Read all CLI arguments
2. Load local config
3. Load global config
4. Try backup: package.main
5. Try backup: package.start
6. Try index.js
================================================
FILE: doc/requireable.md
================================================
# Nodemon as a required module
Nodemon (as of 1.0.0) also works as a required module. At present, you can only require nodemon in to your project once (as there are static config variables), but you can re-run with new settings for a different application to monitor.
By requiring nodemon, you can extend it's functionality. Below is a simple example of using nodemon in your project:
```js
var nodemon = require('nodemon');
nodemon({
script: 'app.js',
ext: 'js json'
});
nodemon.on('start', function () {
console.log('App has started');
}).on('quit', function () {
console.log('App has quit');
process.exit();
}).on('restart', function (files) {
console.log('App restarted due to: ', files);
});
```
Nodemon will emit a number of [events](https://github.com/remy/nodemon/blob/master/doc/events.md) by default, and when in verbose mode will also emit a `log` event (which matches what the nodemon cli tool echos).
## Arguments
The `nodemon` function takes either an object (that matches the [nodemon config](https://github.com/remy/nodemon#config-files)) or can take a string that matches the arguments that would be used on the command line:
```js
var nodemon = require('nodemon');
nodemon('-e "js json" app.js');
```
## Methods & Properties
The `nodemon` object also has a few methods and properties. Some are exposed to help with tests, but have been listed here for completeness:
### Event handling
This is the event emitter bus that exists inside nodemon exposed at the top level module (ie. it's the `events` api):
- `nodemon.on(event, fn)`
- `nodemon.addListener(event, fn)`
- `nodemon.once(event, fn)`
- `nodemon.emit(event)`
- `nodemon.removeAllListeners([event])`
Note: there's no `removeListener` (happy to take a pull request if it's needed).
### Test utilities
- `nodemon.reset()` - reverts nodemon's internal state to a clean slate
- `nodemon.config` - a reference to the internal config nodemon uses
================================================
FILE: doc/rules.md
================================================
# Rules
Given a nodemon.json file that contains:
```json
{
"ignore": ["*.coffee"],
"watch": ["server/*.coffee", "test/"]
}
```
Then nodemon detects changes, but what causes nodemon to restart? The ignored files or the watched files? Which wins?
```js
const files = ['server/foo.coffee', 'server/app.js'];
// afterIgnore = ['server/app.js'] now since foo.coffee matches *.coffee
const afterIgnore = files.filter(applyIgnore);
// watch = ['server/foo.coffee'] as it's under the watch
const watched = files.filter(applyWatch);
```
What about:
```js
const files = ['test/app.js', 'test/app.coffee'];
// afterIgnore = ['test/app.js'] now since test/app.coffee matches *.coffee
const afterIgnore = files.filter(applyIgnore);
// watch.length = 2 as watch implies test/*.*
const watched = files.filter(applyWatch);
```
================================================
FILE: doc/sample-nodemon.md
================================================
# Sample nodemon.json
Here is an example (of a contrived) `nodemon.json` file:
```json
{
"restartable": "rs",
"ignore": [
".git",
"node_modules/**/node_modules"
],
"verbose": true,
"execMap": {
"js": "node --harmony"
},
"events": {
"restart": "osascript -e 'display notification \"App restarted due to:\n'$FILENAME'\" with title \"nodemon\"'"
},
"watch": [
"test/fixtures/",
"test/samples/"
],
"env": {
"NODE_ENV": "development"
},
"ext": "js,json"
}
```
Note that the `ignore` used is nodemon's default ignore rule. The complete defaults can be seen here: [defaults.js](https://github.com/remy/nodemon/blob/master/lib/config/defaults.js).
================================================
FILE: faq.md
================================================
# FAQ
This is being added to as common issues occur on the [issues](http://github.com/remy/nodemon/issues), and where appropriate the answers will be added here.
This is a working document, and if it makes sense, I'll take pull requests to help make it better.
# How to clear the console on restart
Rather than being a(nother) feature in nodemon, and as per the [design principles](https://github.com/remy/nodemon#design-principles) you can clear the console using nodemon's existing architecture.
In your `nodemon.json` (or in your `package.json`) you can include the follow event handler to always clear the console when nodemon starts:
```json
{
"events": {
"start": "cls || clear"
}
}
```
Note that on Windows, this will clear the scroll buffer too. If you try to use node to clear the screen, you may have a race condition between the boot time of your process and the start event. This method should be the fastest.
# nodemon doesn't restart on .env change
This is an edge case with how nodemon watches files. This is because nodemon doesn't know if `.env` is a hidden file with no extension or a `*.env` without a filename.
Nonetheless, to trigger a change on `.env` (or similar files like `.bash_profile`), you need to explicitly tell nodemon to watch the file.
However, now nodemon will *only* watch the `.env` file, so you need to add to what nodemon is watching, i.e. tell nodemon to _also_ watch the current working directory:
```bash
$ nodemon --watch .env --watch app app/index.js
```
# nodemon doesn't work with my REPL
Create an nodemon.json file with the setting:
```js
{
"restartable": false
}
```
This will leave the STDIN to your application rather than listening for the `rs` command to restart.
# Strange/failing behaviour starting the (node-based) executable
By default, nodemon will try to fork your node scripts ([background reading](https://github.com/remy/nodemon/issues/1025)), however, there are some edge cases where that won't suit your needs. Most of the time the default configuration should be fine, but if you want to force nodemon to spawn your node process, use the `--spawn` option.
# My script arguments are being taken by nodemon
Use the `--` switch to tell nodemon to ignore all arguments after this point. So to pass `-L` to your script instead of nodemon, use:
```
$ nodemon app.js -- -L -opt2 -opt3
```
nodemon will ignore all script arguments after `--` and pass them to your script.
# Error: "process failed, unhandled exit code (2)"
Nodemon will look for exit signals from the child process it runs. When the exit code is `2`, nodemon throws an error. Typically this is because the arguments are bad for the executing program, but it can also be due other reasons.
For example, mocha@3.x will exit with `2` on failing tests. To handle the exit code in a way that nodemon can consume, manually exit the process, i.e.:
```bash
nodemon -x 'mocha test/bad.test.js || exit 1'
```
# You want to suppress the request for support message
Perhaps you're [already supporting nodemon](https://opencollective.com/nodemon) or you're using it in CI and it needs to be quietened.
Include the environment value of `SUPPRESS_SUPPORT=1`.
# Can't install nodemon: permission issue
You may need to install nodemon using `sudo` (which isn't recommended, but I understand it's unavoidable in some environments). If the install fails with this appearing in the npm error log, then you need the following workaround.
```
gyp WARN EACCES user "root" does not have permission to access the dev dir "<some-local-dir>"
```
Try to re-install adding `--unsafe-perm` to the arguments:
```
sudo npm install -g nodemon --unsafe-perm
```
Ref [#713](https://github.com/remy/nodemon/issues/713)
# Help! My changes aren't being detected!
nodemon (from 1.4.2 onwards) uses [Chokidar](https://www.npmjs.com/package/chokidar) as its underlying watch system.
If you find your files aren't being monitored, either nodemon isn't restarting, or it reports that zero files are being watched, then you may need the polling mode.
To enable polling use the legacy flag either via the terminal:
```shell
$ nodemon --legacy-watch
$ nodemon -L # short alias
```
Or via the `nodemon.json`:
```json
{
"legacyWatch": true
}
```
## nodemon tries to run two scripts
If you see nodemon trying to run two scripts, like:
```
9 Dec 23:52:58 - [nodemon] starting `node ./app.js fixtures/sigint.js`
```
This is because the main script argument (`fixtures/sigint.js` in this case) wasn't found, and a `package.json`'s main file _was_ found. ie. to solve, double check the path to your script is correct.
## What has precedence, ignore or watch?
Everything under the ignore rule has the final word. So if you ignore the `node_modules` directory, but watch `node_modules/*.js`, then all changed files will be ignored, because any changed .js file in the `node_modules` are ignored.
However, there are defaults in the ignore rules that your rules will be merged with, and not override. To override the ignore rules see [overriding the underlying default ignore rules](#overriding-the-underlying-default-ignore-rules).
## Overriding the underlying default ignore rules
The way the ignore rules work is that your rules are merged with the `ignoreRoot` rules, which contain `['.git', 'node_modules', ...]`. So if you ignore `public`, the ignore rule results in `['.git', 'node_modules', ..., 'public']`.
Say you did want to watch the `node_modules` directory. You have to override the `ignoreRoot`. If you wanted this on a per project basis, add the config to you local `nodemon.json`. If you want it for all projects, add it to `$HOME/nodemon.json`:
```json
{
"ignoreRoot": [".git"]
}
```
Now when ignoring `public`, the ignore rule results in `['.git', 'public']`, and nodemon will restart on `node_modules` changes.
## nodemon doesn't work with fedora
Fedora is looking for `nodejs` rather than `node` which is the binary that nodemon kicks off.
A workaround is to make sure that `node` binary exists in the `PATH`:
```bash
sudo ln -s /usr/bin/nodejs /usr/local/bin/node
```
Alternatively the `--exec nodejs` option can be used.
Fedora and Ubuntu package node as nodejs, because node.dpkg is
> Description-en: Amateur Packet Radio Node program
> The node program accepts TCP/IP and packet radio network connections and
> presents users with an interface that allows them to make gateway connections
> to remote hosts using a variety of amateur radio protocols.
> They make the binary is nodejs, rather than node. So long as you're not using that Packet Radio Node Program mentioned above the workaround will work.
Thank you [@EvanCarroll](https://github.com/remy/nodemon/issues/68#issuecomment-13672509)
## Using nodemon with forever
If you're using nodemon with [forever](https://github.com/foreverjs/forever) (perhaps in a production environment), you can combine the two together. This way if the script crashes, forever restarts the script, and if there are file changes, nodemon restarts your script. For more detail, see [issue 30](https://github.com/remy/nodemon/issues/30).
To achieve this you need to add the following on the call to `forever`:
* Use forever's `-c nodemon` option to tell forever to run `nodemon` instead of `node`.
* Include the nodemon `--exitcrash` flag to ensure nodemon exits if the script crashes (or exits unexpectedly).
* Tell forever to use `SIGTERM` instead of `SIGKILL` when requesting nodemon to stop. This ensures that nodemon can stop the watched node process cleanly.
* Optionally add the `--uid` parameter, adding a unique name for your process. In the example, the uid is set to `foo`.
```bash
forever start --uid foo --killSignal=SIGTERM -c 'nodemon --exitcrash' server.js
```
To test this, you can kill the server.js process and forever will restart it. If you `touch server.js` nodemon will restart it.
To stop the process monitored by forever and nodemon, call the following, using the `uid` we assigned above (`foo`):
```bash
forever stop foo
```
This will stop both nodemon and the node process it was monitoring.
Note that I _would not_ recommend using nodemon in a production environment - but that's because I wouldn't want it restart without my explicit instruction.
## What does "verbose" give me?
The `--verbose` (or `-V`) puts nodemon in verbose mode which adds some detail to starting and restarting.
Additional restart information:
* Which nodemon configs are loaded (local and global if found)
* Which ignore rules are being applied
* Which file extensions are being watch
* The process ID of your application (the `child pid`)
* The process ID of nodemon to manually trigger restarts via kill signals
For example:
```text
14 Apr 15:24:58 - [nodemon] v1.0.17
14 Apr 15:24:58 - [nodemon] reading config /Users/remy/Sites/jsbin-private/nodemon.json
14 Apr 15:24:58 - [nodemon] to restart at any time, enter `rs`
14 Apr 15:24:58 - [nodemon] or send SIGHUP to 58118 to restart
14 Apr 15:24:58 - [nodemon] ignoring: /Users/remy/Sites/jsbin-private/.git/**/* node_modules/**/node_modules
14 Apr 15:24:58 - [nodemon] watching: /Users/remy/Sites/jsbin/views/**/* /Users/remy/Sites/jsbin/lib/**/* ../json/*.json config.dev.json
14 Apr 15:24:58 - [nodemon] watching extensions: json,js,html
14 Apr 15:24:58 - [nodemon] starting `node run.js`
14 Apr 15:24:58 - [nodemon] child pid: 9292
```
When nodemon detects a change, the following addition information is shown:
* Which file(s) triggered the check
* Which (if any) rules the file matched to cause a subsequent restart
* How many rules were matched and out of those rules, how many cause a restart
* A list of all the files that _successfully_ caused a restart
For example, on `lib/app.js` being changed:
```text
14 Apr 15:25:56 - [nodemon] files triggering change check: ../jsbin/lib/app.js
14 Apr 15:25:56 - [nodemon] matched rule: **/Users/remy/Sites/jsbin/lib/**/*
14 Apr 15:25:56 - [nodemon] changes after filters (before/after): 1/1
14 Apr 15:25:56 - [nodemon] restarting due to changes...
14 Apr 15:25:56 - [nodemon] ../jsbin/lib/app.js
14 Apr 15:25:56 - [nodemon] starting `node run.js`
14 Apr 15:25:56 - [nodemon] child pid: 9556
```
## My .nodemonignore is being ignored
_The legacy `.nodemonignore` was dropped in nodemon@3_
The new `nodemon.json` supersedes the `.nodemonignore` file, so if you have both, the `.nodemonignore` is not used at all.
Note that if you have a `nodemon.json` in your `$HOME` path, then this will also supersede the old ignore file (and the _legacy_ format config is ignored).
## nodemon does nothing
On Ubuntu globally installed node applications have been found to have no output when they're run. This _seems_ to be an issue with node not being correctly installed (possibly linked to the binary having to be called `nodejs`).
The solution (that's worked in the past) is to install [nvm](https://github.com/creationix/nvm) first and using it to install node, _rather_ than using `apt-get` (or similar tools) to install node directly.
## If nodemon is facing the watch errors (Mac & Linux)
Try the following command on terminal:
```bash
echo fs.inotify.max_user_watches=582222 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
```
## "Port in use" with --inspect flag and docker
The workaround is to use [kill-port](https://github.com/tiaanduplessis/kill-port) to close off the debugger port, used similarly to:
```bash
nodemon --delay 80ms --exec 'kill-port -k 9228/tcp; node --inspect=0.0.0.0:9228 ./app/http.js'
```
[Original suggestion here](https://github.com/remy/nodemon/issues/1050#issuecomment-323680697) and [addition information here](https://github.com/remy/nodemon/issues/1346#issuecomment-401218386).
## Windows: nodemon keeps restarting without changes
This _might_ be related to a Microsoft Windows release pertaining to the OS and breaking `fsevents` module (which is used by [chokidar](https://github.com/paulmillr/chokidar) - the underlying watch package).
The workaround is to run the following command:
```bash
fsutil behavior set disablelastaccess 1
```
[Futher reading thread](https://github.com/remy/nodemon/issues/1354)
## Error: Cannot find module 'internal/util/types'
If you see the error `Cannot find module 'internal/util/types'`, the error is solved with a clean npm cache and trying to reinstall the dependency you're working with.
A start is to use the following commands:
```
sudo npm cache clean --force
sudo npm i -g npm
```
Otherwise see [issue #1124](https://github.com/remy/nodemon/issues/1124) for further suggestions.
## No automatic restart when using Docker volumes [issue #419](https://github.com/remy/nodemon/issues/419#issuecomment-391244911)
Some Node.js Docker images do not seem to have the full suite of filesystem process utilities that allow `nodemon` to restart automatically when the code in a mounted volume changes. To handle this, and enable automatic restarts without using legacy mode, you can install the [procps](http://procps.sourceforge.net) package.
Here's an example snippet of a Dockerfile:
```
FROM node:8.9.4-wheezy
RUN apt-get update && apt-get install -y procps
```
## "scripts is disabled on this system" on Windows
Based on [this issue](https://github.com/remy/nodemon/issues/1619), if you see the following on Windows:
```
PS> nodemon app.js
nodemon : File C:\…\nodemon.ps1 cannot be loaded because running scripts is disabled on this system. For more
information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
CategoryInfo : SecurityError: (:) [], PSSecurityException
FullyQualifiedErrorId : UnauthorizedAccess
```
The solution is as follows by [Felipe Jacob](https://github.com/adelbs):
It's a security restriction of the Windows PowerShell.
1. Open up a powershell command window (open it as administrator)
2. To check out current restrictions type "Get-ExecutionPolicy"
3. Enable powershell by typing "Set-ExecutionPolicy remotesigned"
## How can I watch all file types in a folder?
To watch all file types, use `'*'`:
```bash
nodemon --ext '*' --watch public --exec 'python -m SimpleHTTPServer'
```
## Workaround for when --inspect flag is passed and the old process doesn't finish before starting a new process
Based on [this issue](https://github.com/remy/nodemon/issues/2056).
Sometimes when using the `--inspect` flag, nodemon will try to start the a process before the old process is finished.
This will cause an error trying to up the new process because of the debugger service:
```
[0] [nodemon] restarting due to changes...
[0] [nodemon] starting `node --inspect ./main/index.js`
[0] Starting inspector on 127.0.0.1:9229 failed: address already in use
```
Your application will likely be running the old version code if you see that message, and you will need to stop the app and manually start it again to run the app with the newer code version.
A common cause for this is when graceful shutdowns are doing async tasks, i.e:
```
// ensure this is `on` and not `once`
process.on('SIGUSR2', async () => {
await db.disconnect()
process.kill(process.pid, 'SIGTERM');
})
```
Simply removing the `await` keyword would likely fix the issue.
If even after that you still running into that problem, there's a workaround to force kill the debugger whenever nodemon triggers a restart.
You can create a `nodemon.json` file at the project root and add the following config:
```
{
"events": {
"restart": "sh -c 'lsof -i :${PORT:-9229} -t | xargs kill'"
}
}
```
This will run a shell command to kill the process running on the PORT 9229 (default node debug port) whenever nodemon triggers a restart.
It may fail sometimes, but it makes the hot reload works partially.
================================================
FILE: index.d.ts
================================================
import type { WatchOptions } from 'chokidar';
export type NodemonEventHandler =
| 'start'
| 'crash'
| 'exit'
| 'quit'
| 'restart'
| 'config:update'
| 'log'
| 'readable'
| 'stdout'
| 'stderr';
export type NodemonEventListener = {
on(event: 'start' | 'crash' | 'readable', listener: () => void): Nodemon;
on(event: 'log', listener: (e: NodemonEventLog) => void): Nodemon;
on(event: 'stdout' | 'stderr', listener: (e: string) => void): Nodemon;
on(event: 'restart', listener: (files?: string[]) => void): Nodemon;
on(event: 'quit', listener: (e?: NodemonEventQuit) => void): Nodemon;
on(event: 'exit', listener: (e?: number) => void): Nodemon;
on(
event: 'config:update',
listener: (e?: NodemonEventConfig) => void,
): Nodemon;
};
export type NodemonEventLog = {
/**
- detail: what you get with nodemon --verbose.
- status: subprocess starting, restarting.
- fail: is the subprocess crashing.
- error: is a nodemon system error.
*/
type: 'detail' | 'log' | 'status' | 'error' | 'fail';
/** the plain text message */
message: string;
/** contains the terminal escape codes to add colour, plus the "[nodemon]" prefix */
colour: string;
};
export type NodemonEventQuit = 143 | 130;
export type NodemonEventConfig = {
run: boolean;
system: {
cwd: string;
};
required: boolean;
dirs: string[];
timeout: number;
options: NodemonConfig;
lastStarted: number;
loaded: string[];
load: (
settings: NodemonSettings,
ready: (config: NodemonEventConfig) => void,
) => void;
reset: () => void;
};
export interface NodemonExecOptions {
script: string;
scriptPosition?: number;
args?: string[];
ext?: string; // "js,mjs" etc (should really support an array of strings, but I don't think it does right now)
exec?: string; // node, python, etc
execArgs?: string[]; // args passed to node, etc,
nodeArgs?: string[]; // args passed to node, etc,
}
export interface NodemonConfig {
/** restartable defaults to "rs" as a string the user enters */
restartable?: false | string;
colours?: boolean;
execMap?: { [key: string]: string };
ignoreRoot?: string[];
watch?: string[];
ignore?: string[];
stdin?: boolean;
runOnChangeOnly?: boolean;
verbose?: boolean;
signal?: string;
stdout?: boolean;
watchOptions?: WatchOptions;
help?: string;
version?: boolean;
cwd?: string;
dump?: boolean;
delay?: number;
monitor?: string[];
spawn?: boolean;
noUpdateNotifier?: boolean;
legacyWatch?: boolean;
pollingInterval?: number;
/** @deprecated as this is "on" by default */
js?: boolean;
quiet?: boolean;
configFile?: string;
exitCrash?: boolean;
execOptions?: NodemonExecOptions;
}
export interface NodemonSettings extends NodemonConfig, NodemonExecOptions {
events?: Record<string, string>;
env?: Record<string, string>;
}
export type Nodemon = {
(settings: NodemonSettings): Nodemon;
removeAllListeners(event: NodemonEventHandler): Nodemon;
emit(type: NodemonEventHandler, event?: any): Nodemon;
reset(callback: Function): Nodemon;
restart(): Nodemon;
config: NodemonSettings;
} & NodemonEventListener & {
[K in keyof NodemonEventListener as 'addListener']: NodemonEventListener[K];
} & {
[K in keyof NodemonEventListener as 'once']: NodemonEventListener[K];
};
declare const nodemon: Nodemon;
export = nodemon;
================================================
FILE: jsconfig.json
================================================
{
"compilerOptions": {
"typeRoots": ["./index.d.ts", "./node_modules/@types"],
"checkJs": true
},
"exclude": ["node_modules"]
}
================================================
FILE: lib/cli/index.js
================================================
var parse = require('./parse');
/**
* Converts a string to command line args, in particular
* groups together quoted values.
* This is a utility function to allow calling nodemon as a required
* library, but with the CLI args passed in (instead of an object).
*
* @param {String} string
* @return {Array}
*/
function stringToArgs(string) {
var args = [];
var parts = string.split(' ');
var length = parts.length;
var i = 0;
var open = false;
var grouped = '';
var lead = '';
for (; i < length; i++) {
lead = parts[i].substring(0, 1);
if (lead === '"' || lead === '\'') {
open = lead;
grouped = parts[i].substring(1);
} else if (open && parts[i].slice(-1) === open) {
open = false;
grouped += ' ' + parts[i].slice(0, -1);
args.push(grouped);
} else if (open) {
grouped += ' ' + parts[i];
} else {
args.push(parts[i]);
}
}
return args;
}
module.exports = {
parse: function (argv) {
if (typeof argv === 'string') {
argv = stringToArgs(argv);
}
return parse(argv);
},
};
================================================
FILE: lib/cli/parse.js
================================================
/*
nodemon is a utility for node, and replaces the use of the executable
node. So the user calls `nodemon foo.js` instead.
nodemon can be run in a number of ways:
`nodemon` - tries to use package.json#main property to run
`nodemon` - if no package, looks for index.js
`nodemon app.js` - runs app.js
`nodemon --arg app.js --apparg` - eats arg1, and runs app.js with apparg
`nodemon --apparg` - as above, but passes apparg to package.json#main (or
index.js)
`nodemon --debug app.js
*/
var fs = require('fs');
var path = require('path');
var existsSync = fs.existsSync || path.existsSync;
module.exports = parse;
/**
* Parses the command line arguments `process.argv` and returns the
* nodemon options, the user script and the executable script.
*
* @param {Array<string> | string} argv full process arguments, including `node` leading arg
* @return {Object} { options, script, args }
*/
function parse(argv) {
if (typeof argv === 'string') {
argv = argv.split(' ');
}
var eat = function (i, args) {
if (i <= args.length) {
return args.splice(i + 1, 1).pop();
}
};
var args = argv.slice(2);
var script = null;
var nodemonOptions = { scriptPosition: null };
var nodemonOpt = nodemonOption.bind(null, nodemonOptions);
var lookForArgs = true;
// move forward through the arguments
for (var i = 0; i < args.length; i++) {
// if the argument looks like a file, then stop eating
if (!script) {
if (args[i] === '.' || existsSync(args[i])) {
script = args.splice(i, 1).pop();
// we capture the position of the script because we'll reinsert it in
// the right place in run.js:command (though I'm not sure we should even
// take it out of the array in the first place, but this solves passing
// arguments to the exec process for now).
nodemonOptions.scriptPosition = i;
i--;
continue;
}
}
if (lookForArgs) {
// respect the standard way of saying: hereafter belongs to my script
if (args[i] === '--') {
args.splice(i, 1);
nodemonOptions.scriptPosition = i;
// cycle back one argument, as we just ate this one up
i--;
// ignore all further nodemon arguments
lookForArgs = false;
// move to the next iteration
continue;
}
if (nodemonOpt(args[i], eat.bind(null, i, args)) !== false) {
args.splice(i, 1);
// cycle back one argument, as we just ate this one up
i--;
}
}
}
nodemonOptions.script = script;
nodemonOptions.args = args;
return nodemonOptions;
}
/**
* Given an argument (ie. from process.argv), sets nodemon
* options and can eat up the argument value
*
* @param {import('../..').NodemonSettings} options object that will be updated
* @param {String} arg current argument from argv
* @param {Function} eatNext the callback to eat up the next argument in argv
* @return {Boolean} false if argument was not a nodemon arg
*/
function nodemonOption(options, arg, eatNext) {
// line separation on purpose to help legibility
if (arg === '--help' || arg === '-h' || arg === '-?') {
var help = eatNext();
options.help = help ? help : true;
} else
if (arg === '--version' || arg === '-v') {
options.version = true;
} else
if (arg === '--no-update-notifier') {
options.noUpdateNotifier = true;
} else
if (arg === '--spawn') {
options.spawn = true;
} else
if (arg === '--dump') {
options.dump = true;
} else
if (arg === '--verbose' || arg === '-V') {
options.verbose = true;
} else
if (arg === '--legacy-watch' || arg === '-L') {
options.legacyWatch = true;
} else
if (arg === '--polling-interval' || arg === '-P') {
options.pollingInterval = parseInt(eatNext(), 10);
} else
// Depricated as this is "on" by default
if (arg === '--js') {
options.js = true;
} else
if (arg === '--quiet' || arg === '-q') {
options.quiet = true;
} else
if (arg === '--config') {
options.configFile = eatNext();
} else
if (arg === '--watch' || arg === '-w') {
if (!options.watch) { options.watch = []; }
options.watch.push(eatNext());
} else
if (arg === '--ignore' || arg === '-i') {
if (!options.ignore) { options.ignore = []; }
options.ignore.push(eatNext());
} else
if (arg === '--exitcrash') {
options.exitCrash = true;
} else
if (arg === '--delay' || arg === '-d') {
options.delay = parseDelay(eatNext());
} else
if (arg === '--exec' || arg === '-x') {
options.exec = eatNext();
} else
if (arg === '--no-stdin' || arg === '-I') {
options.stdin = false;
} else
if (arg === '--on-change-only' || arg === '-C') {
options.runOnChangeOnly = true;
} else
if (arg === '--ext' || arg === '-e') {
options.ext = eatNext();
} else
if (arg === '--no-colours' || arg === '--no-colors') {
options.colours = false;
} else
if (arg === '--signal' || arg === '-s') {
options.signal = eatNext();
} else
if (arg === '--cwd') {
options.cwd = eatNext();
// go ahead and change directory. This is primarily for nodemon tools like
// grunt-nodemon - we're doing this early because it will affect where the
// user script is searched for.
process.chdir(path.resolve(options.cwd));
} else {
// this means we didn't match
return false;
}
}
/**
* Given an argument (ie. from nodemonOption()), will parse and return the
* equivalent millisecond value or 0 if the argument cannot be parsed
*
* @param {String} value argument value given to the --delay option
* @return {Number} millisecond equivalent of the argument
*/
function parseDelay(value) {
var millisPerSecond = 1000;
var millis = 0;
if (value.match(/^\d*ms$/)) {
// Explicitly parse for milliseconds when using ms time specifier
millis = parseInt(value, 10);
} else {
// Otherwise, parse for seconds, with or without time specifier then convert
millis = parseFloat(value) * millisPerSecond;
}
return isNaN(millis) ? 0 : millis;
}
================================================
FILE: lib/config/command.js
================================================
module.exports = command;
/**
* command constructs the executable command to run in a shell including the
* user script, the command arguments.
*
* @param {Object} settings Object as:
* { execOptions: {
* exec: String,
* [script: String],
* [scriptPosition: Number],
* [execArgs: Array<string>]
* }
* }
* @return {Object} an object with the node executable and the
* arguments to the command
*/
function command(settings) {
var options = settings.execOptions;
var executable = options.exec;
var args = [];
// after "executable" go the exec args (like --debug, etc)
if (options.execArgs) {
[].push.apply(args, options.execArgs);
}
// then goes the user's script arguments
if (options.args) {
[].push.apply(args, options.args);
}
// after the "executable" goes the user's script
if (options.script) {
args.splice((options.scriptPosition || 0) +
options.execArgs.length, 0, options.script);
}
return {
executable: executable,
args: args,
};
}
================================================
FILE: lib/config/defaults.js
================================================
var ignoreRoot = require('ignore-by-default').directories();
// default options for config.options
const defaults = {
restartable: 'rs',
colours: true,
execMap: {
py: 'python',
rb: 'ruby',
ts: 'ts-node',
// more can be added here such as ls: lsc - but please ensure it's cross
// compatible with linux, mac and windows, or make the default.js
// dynamically append the `.cmd` for node based utilities
},
ignoreRoot: ignoreRoot.map((_) => `**/${_}/**`),
watch: ['*.*'],
stdin: true,
runOnChangeOnly: false,
verbose: false,
signal: 'SIGUSR2',
// 'stdout' refers to the default behaviour of a required nodemon's child,
// but also includes stderr. If this is false, data is still dispatched via
// nodemon.on('stdout/stderr')
stdout: true,
watchOptions: {},
};
const nodeOptions = process.env.NODE_OPTIONS || ''; // ?
if (/--(loader|import)\b/.test(nodeOptions)) {
delete defaults.execMap.ts;
}
module.exports = defaults;
================================================
FILE: lib/config/exec.js
================================================
const path = require('path');
const fs = require('fs');
const existsSync = fs.existsSync;
const utils = require('../utils');
module.exports = exec;
module.exports.expandScript = expandScript;
/**
* Reads the cwd/package.json file and looks to see if it can load a script
* and possibly an exec first from package.main, then package.start.
*
* @return {Object} exec & script if found
*/
function execFromPackage() {
// doing a try/catch because we can't use the path.exist callback pattern
// or we could, but the code would get messy, so this will do exactly
// what we're after - if the file doesn't exist, it'll throw.
try {
// note: this isn't nodemon's package, it's the user's cwd package
var pkg = require(path.join(process.cwd(), 'package.json'));
if (pkg.main !== undefined) {
// no app found to run - so give them a tip and get the feck out
return { exec: null, script: pkg.main };
}
if (pkg.scripts && pkg.scripts.start) {
const parts = pkg.scripts.start.split(' ');
// fixes a loop issue where the script repeats over and over #2258
if (parts.includes('nodemon')) {
return null;
}
return { exec: pkg.scripts.start };
}
} catch (e) {}
return null;
}
function replace(map, str) {
var re = new RegExp('{{(' + Object.keys(map).join('|') + ')}}', 'g');
return str.replace(re, function (all, m) {
return map[m] || all || '';
});
}
function expandScript(script, ext) {
if (!ext) {
ext = '.js';
}
if (script.indexOf(ext) !== -1) {
return script;
}
if (existsSync(path.resolve(script))) {
return script;
}
if (existsSync(path.resolve(script + ext))) {
return script + ext;
}
return script;
}
/**
* Discovers all the options required to run the script
* and if a custom exec has been passed in, then it will
* also try to work out what extensions to monitor and
* whether there's a special way of running that script.
*
* @param {Object} nodemonOptions
* @param {Object} execMap
* @return {Object} new and updated version of nodemonOptions
*/
function exec(nodemonOptions, execMap) {
if (!execMap) {
execMap = {};
}
var options = utils.clone(nodemonOptions || {});
var script;
// if there's no script passed, try to get it from the first argument
if (!options.script && (options.args || []).length) {
script = expandScript(
options.args[0],
options.ext && '.' + (options.ext || 'js').split(',')[0]
);
// if the script was found, shift it off our args
if (script !== options.args[0]) {
options.script = script;
options.args.shift();
}
}
// if there's no exec found yet, then try to read it from the local
// package.json this logic used to sit in the cli/parse, but actually the cli
// should be parsed first, then the user options (via nodemon.json) then
// finally default down to pot shots at the directory via package.json
if (!options.exec && !options.script) {
var found = execFromPackage();
if (found !== null) {
if (found.exec) {
options.exec = found.exec;
}
if (!options.script) {
options.script = found.script;
}
if (Array.isArray(options.args) && options.scriptPosition === null) {
options.scriptPosition = options.args.length;
}
}
}
// var options = utils.clone(nodemonOptions || {});
script = path.basename(options.script || '');
var scriptExt = path.extname(script).slice(1);
var extension = options.ext;
if (extension === undefined) {
var isJS = scriptExt === 'js' || scriptExt === 'mjs' || scriptExt === 'cjs';
extension = isJS || !scriptExt ? 'js,mjs,cjs' : scriptExt;
extension += ',json'; // Always watch JSON files
}
var execDefined = !!options.exec;
// allows the user to simplify cli usage:
// https://github.com/remy/nodemon/issues/195
// but always give preference to the user defined argument
if (!options.exec && execMap[scriptExt] !== undefined) {
options.exec = execMap[scriptExt];
execDefined = true;
}
options.execArgs = nodemonOptions.execArgs || [];
if (Array.isArray(options.exec)) {
options.execArgs = options.exec;
options.exec = options.execArgs.shift();
}
if (options.exec === undefined) {
options.exec = 'node';
} else {
// allow variable substitution for {{filename}} and {{pwd}}
var substitution = replace.bind(null, {
filename: options.script,
pwd: process.cwd(),
});
var newExec = substitution(options.exec);
if (
newExec !== options.exec &&
options.exec.indexOf('{{filename}}') !== -1
) {
options.script = null;
}
options.exec = newExec;
var newExecArgs = options.execArgs.map(substitution);
if (newExecArgs.join('') !== options.execArgs.join('')) {
options.execArgs = newExecArgs;
delete options.script;
}
}
if (options.exec === 'node' && options.nodeArgs && options.nodeArgs.length) {
options.execArgs = options.execArgs.concat(options.nodeArgs);
}
// note: indexOf('coffee') handles both .coffee and .litcoffee
if (
!execDefined &&
options.exec === 'node' &&
scriptExt.indexOf('coffee') !== -1
) {
options.exec = 'coffee';
// we need to get execArgs set before the script
// for example, in `nodemon --debug my-script.coffee --my-flag`, debug is an
// execArg, while my-flag is a script arg
var leadingArgs = (options.args || []).splice(0, options.scriptPosition);
options.execArgs = options.execArgs.concat(leadingArgs);
options.scriptPosition = 0;
if (options.execArgs.length > 0) {
// because this is the coffee executable, we need to combine the exec args
// into a single argument after the nodejs flag
options.execArgs = ['--nodejs', options.execArgs.join(' ')];
}
}
if (options.exec === 'coffee') {
// don't override user specified extension tracking
if (options.ext === undefined) {
if (extension) {
extension += ',';
}
extension += 'coffee,litcoffee';
}
// because windows can't find 'coffee', it needs the real file 'coffee.cmd'
if (utils.isWindows) {
options.exec += '.cmd';
}
}
// allow users to make a mistake on the extension to monitor
// converts .js, pug => js,pug
// BIG NOTE: user can't do this: nodemon -e *.js
// because the terminal will automatically expand the glob against
// the file system :(
extension = (extension.match(/[^,*\s]+/g) || [])
.map((ext) => ext.replace(/^\./, ''))
.join(',');
options.ext = extension;
if (options.script) {
options.script = expandScript(
options.script,
extension && '.' + extension.split(',')[0]
);
}
options.env = {};
// make sure it's an object (and since we don't have )
if ({}.toString.apply(nodemonOptions.env) === '[object Object]') {
options.env = utils.clone(nodemonOptions.env);
} else if (nodemonOptions.env !== undefined) {
throw new Error('nodemon env values must be an object: { PORT: 8000 }');
}
return options;
}
================================================
FILE: lib/config/index.js
================================================
/**
* Manages the internal config of nodemon, checking for the state of support
* with fs.watch, how nodemon can watch files (using find or fs methods).
*
* This is *not* the user's config.
*/
var debug = require('debug')('nodemon');
var load = require('./load');
var rules = require('../rules');
var utils = require('../utils');
var pinVersion = require('../version').pin;
var command = require('./command');
var rulesToMonitor = require('../monitor/match').rulesToMonitor;
var bus = utils.bus;
function reset() {
rules.reset();
config.dirs = [];
config.options = { ignore: [], watch: [], monitor: [] };
config.lastStarted = 0;
config.loaded = [];
}
var config = {
run: false,
system: {
cwd: process.cwd(),
},
required: false,
dirs: [],
timeout: 1000,
options: {},
};
/**
* Take user defined settings, then detect the local machine capability, then
* look for local and global nodemon.json files and merge together the final
* settings with the config for nodemon.
*
* @param {Object} settings user defined settings for nodemon (typically on
* the cli)
* @param {Function} ready callback fired once the config is loaded
*/
config.load = function (settings, ready) {
reset();
var config = this;
load(settings, config.options, config, function (options) {
config.options = options;
if (options.watch.length === 0) {
// this is to catch when the watch is left blank
options.watch.push('*.*');
}
if (options['watch_interval']) { // jshint ignore:line
options.watchInterval = options['watch_interval']; // jshint ignore:line
}
config.watchInterval = options.watchInterval || null;
if (options.signal) {
config.signal = options.signal;
}
var cmd = command(config.options);
config.command = {
raw: cmd,
string: utils.stringify(cmd.executable, cmd.args),
};
// now run automatic checks on system adding to the config object
options.monitor = rulesToMonitor(options.watch, options.ignore, config);
var cwd = process.cwd();
debug('config: dirs', config.dirs);
if (config.dirs.length === 0) {
config.dirs.unshift(cwd);
}
bus.emit('config:update', config);
pinVersion().then(function () {
ready(config);
}).catch(e => {
// this doesn't help testing, but does give exposure on syntax errors
console.error(e.stack);
setTimeout(() => { throw e; }, 0);
});
});
};
config.reset = reset;
module.exports = config;
================================================
FILE: lib/config/load.js
================================================
var debug = require('debug')('nodemon');
var fs = require('fs');
var path = require('path');
var exists = fs.exists || path.exists;
var utils = require('../utils');
var rules = require('../rules');
var parse = require('../rules/parse');
var exec = require('./exec');
var defaults = require('./defaults');
module.exports = load;
module.exports.mutateExecOptions = mutateExecOptions;
var existsSync = fs.existsSync || path.existsSync;
function findAppScript() {
// nodemon has been run alone, so try to read the package file
// or try to read the index.js file
var pkg =
existsSync(path.join(process.cwd(), 'package.json')) &&
require(path.join(process.cwd(), 'package.json'));
if ((!pkg || pkg.main == undefined) && existsSync('./index.js')) {
return 'index.js';
}
}
/**
* Load the nodemon config, first reading the global root/nodemon.json, then
* the local nodemon.json to the exec and then overwriting using any user
* specified settings (i.e. from the cli)
*
* @param {Object} settings user defined settings
* @param {Object} options global options
* @param {Object} config the config object to be updated
* @param {Function} callback that receives complete config
*/
function load(settings, options, config, callback) {
config.loaded = [];
// first load the root nodemon.json
loadFile(options, config, utils.home, function (options) {
// then load the user's local configuration file
if (settings.configFile) {
options.configFile = path.resolve(settings.configFile);
}
loadFile(options, config, process.cwd(), function (options) {
// Then merge over with the user settings (parsed from the cli).
// Note that merge protects and favours existing values over new values,
// and thus command line arguments get priority
options = utils.merge(settings, options);
// legacy support
if (!Array.isArray(options.ignore)) {
options.ignore = [options.ignore];
}
if (!options.ignoreRoot) {
options.ignoreRoot = defaults.ignoreRoot;
}
// blend the user ignore and the default ignore together
if (options.ignoreRoot && options.ignore) {
if (!Array.isArray(options.ignoreRoot)) {
options.ignoreRoot = [options.ignoreRoot];
}
options.ignore = options.ignoreRoot.concat(options.ignore);
} else {
options.ignore = defaults.ignore.concat(options.ignore);
}
// add in any missing defaults
options = utils.merge(options, defaults);
if (!options.script && !options.exec) {
var found = findAppScript();
if (found) {
if (!options.args) {
options.args = [];
}
// if the script is found as a result of not being on the command
// line, then we move any of the pre double-dash args in execArgs
const n =
options.scriptPosition === null
? options.args.length
: options.scriptPosition;
options.execArgs = (options.execArgs || []).concat(
options.args.splice(0, n)
);
options.scriptPosition = null;
options.script = found;
}
}
mutateExecOptions(options);
if (options.quiet) {
utils.quiet();
}
if (options.verbose) {
utils.debug = true;
}
// simplify the ready callback to be called after the rules are normalised
// from strings to regexp through the rules lib. Note that this gets
// created *after* options is overwritten twice in the lines above.
var ready = function (options) {
normaliseRules(options, callback);
};
ready(options);
});
});
}
function normaliseRules(options, ready) {
// convert ignore and watch options to rules/regexp
rules.watch.add(options.watch);
rules.ignore.add(options.ignore);
// normalise the watch and ignore arrays
options.watch = options.watch === false ? false : rules.rules.watch;
options.ignore = rules.rules.ignore;
ready(options);
}
/**
* Looks for a config in the current working directory, and a config in the
* user's home directory, merging the two together, giving priority to local
* config. This can then be overwritten later by command line arguments
*
* @param {Function} ready callback to pass loaded settings to
*/
function loadFile(options, config, dir, ready) {
if (!ready) {
ready = function () {};
}
var callback = function (settings) {
// prefer the local nodemon.json and fill in missing items using
// the global options
ready(utils.merge(settings, options));
};
if (!dir) {
return callback({});
}
var filename = options.configFile || path.join(dir, 'nodemon.json');
if (config.loaded.indexOf(filename) !== -1) {
// don't bother re-parsing the same config file
return callback({});
}
fs.readFile(filename, 'utf8', function (err, data) {
if (err) {
if (err.code === 'ENOENT') {
if (!options.configFile && dir !== utils.home) {
// if no specified local config file and local nodemon.json
// doesn't exist, try the package.json
return loadPackageJSON(config, callback);
}
}
return callback({});
}
var settings = {};
try {
settings = JSON.parse(data.toString('utf8').replace(/^\uFEFF/, ''));
if (!filename.endsWith('package.json') || settings.nodemonConfig) {
config.loaded.push(filename);
}
} catch (e) {
utils.log.fail('Failed to parse config ' + filename);
console.error(e);
process.exit(1);
}
// options values will overwrite settings
callback(settings);
});
}
function loadPackageJSON(config, ready) {
if (!ready) {
ready = () => {};
}
const dir = process.cwd();
const filename = path.join(dir, 'package.json');
const packageLoadOptions = { configFile: filename };
return loadFile(packageLoadOptions, config, dir, (settings) => {
ready(settings.nodemonConfig || {});
});
}
function mutateExecOptions(options) {
// work out the execOptions based on the final config we have
options.execOptions = exec(
{
script: options.script,
exec: options.exec,
args: options.args,
scriptPosition: options.scriptPosition,
nodeArgs: options.nodeArgs,
execArgs: options.execArgs,
ext: options.ext,
env: options.env,
},
options.execMap
);
// clean up values that we don't need at the top level
delete options.scriptPosition;
delete options.script;
delete options.args;
delete options.ext;
return options;
}
================================================
FILE: lib/help/index.js
================================================
var fs = require('fs');
var path = require('path');
const supportsColor = require('supports-color');
module.exports = help;
const highlight = supportsColor.stdout ? '\x1B\[$1m' : '';
function help(item) {
if (!item) {
item = 'help';
} else if (item === true) { // if used with -h or --help and no args
item = 'help';
}
// cleanse the filename to only contain letters
// aka: /\W/g but figured this was eaiser to read
item = item.replace(/[^a-z]/gi, '');
try {
var dir = path.join(__dirname, '..', '..', 'doc', 'cli', item + '.txt');
var body = fs.readFileSync(dir, 'utf8');
return body.replace(/\\x1B\[(.)m/g, highlight);
} catch (e) {
return '"' + item + '" help can\'t be found';
}
}
================================================
FILE: lib/index.js
================================================
module.exports = require('./nodemon');
================================================
FILE: lib/monitor/index.js
================================================
module.exports = {
run: require('./run'),
watch: require('./watch').watch,
};
================================================
FILE: lib/monitor/match.js
================================================
const { minimatch } = require('minimatch');
const path = require('path');
const fs = require('fs');
const debug = require('debug')('nodemon:match');
const utils = require('../utils');
module.exports = match;
module.exports.rulesToMonitor = rulesToMonitor;
function rulesToMonitor(watch, ignore, config) {
var monitor = [];
if (!Array.isArray(ignore)) {
if (ignore) {
ignore = [ignore];
} else {
ignore = [];
}
}
if (!Array.isArray(watch)) {
if (watch) {
watch = [watch];
} else {
watch = [];
}
}
if (watch && watch.length) {
monitor = utils.clone(watch);
}
if (ignore) {
[].push.apply(
monitor,
(ignore || []).map(function (rule) {
return '!' + rule;
})
);
}
var cwd = process.cwd();
// next check if the monitored paths are actual directories
// or just patterns - and expand the rule to include *.*
monitor = monitor.map(function (rule) {
var not = rule.slice(0, 1) === '!';
if (not) {
rule = rule.slice(1);
}
if (rule === '.' || rule === '.*') {
rule = '*.*';
}
var dir = path.resolve(cwd, rule);
try {
var stat = fs.statSync(dir);
if (stat.isDirectory()) {
rule = dir;
if (rule.slice(-1) !== '/') {
rule += '/';
}
rule += '**/*';
// `!not` ... sorry.
if (!not) {
config.dirs.push(dir);
}
} else {
// ensures we end up in the check that tries to get a base directory
// and then adds it to the watch list
throw new Error();
}
} catch (e) {
var base = tryBaseDir(dir);
if (!not && base) {
if (config.dirs.indexOf(base) === -1) {
config.dirs.push(base);
}
}
}
if (rule.slice(-1) === '/') {
// just slap on a * anyway
rule += '*';
}
// if the url ends with * but not **/* and not *.*
// then convert to **/* - somehow it was missed :-\
if (
rule.slice(-4) !== '**/*' &&
rule.slice(-1) === '*' &&
rule.indexOf('*.') === -1
) {
if (rule.slice(-2) !== '**') {
rule += '*/*';
}
}
return (not ? '!' : '') + rule;
});
return monitor;
}
function tryBaseDir(dir) {
var stat;
if (/[?*\{\[]+/.test(dir)) {
// if this is pattern, then try to find the base
try {
var base = path.dirname(dir.replace(/([?*\{\[]+.*$)/, 'foo'));
stat = fs.statSync(base);
if (stat.isDirectory()) {
return base;
}
} catch (error) {
// console.log(error);
}
} else {
try {
stat = fs.statSync(dir);
// if this path is actually a single file that exists, then just monitor
// that, *specifically*.
if (stat.isFile() || stat.isDirectory()) {
return dir;
}
} catch (e) { }
}
return false;
}
function match(files, monitor, ext) {
// sort the rules by highest specificity (based on number of slashes)
// ignore rules (!) get sorted highest as they take precedent
const cwd = process.cwd();
var rules = monitor
.sort(function (a, b) {
var r = b.split(path.sep).length - a.split(path.sep).length;
var aIsIgnore = a.slice(0, 1) === '!';
var bIsIgnore = b.slice(0, 1) === '!';
if (aIsIgnore || bIsIgnore) {
if (aIsIgnore) {
return -1;
}
return 1;
}
if (r === 0) {
return b.length - a.length;
}
return r;
})
.map(function (s) {
var prefix = s.slice(0, 1);
if (prefix === '!') {
if (s.indexOf('!' + cwd) === 0) {
return s;
}
// if it starts with a period, then let's get the relative path
if (s.indexOf('!.') === 0) {
return '!' + path.resolve(cwd, s.substring(1));
}
return '!**' + (prefix !== path.sep ? path.sep : '') + s.slice(1);
}
// if it starts with a period, then let's get the relative path
if (s.indexOf('.') === 0) {
return path.resolve(cwd, s);
}
if (s.indexOf(cwd) === 0) {
return s;
}
return '**' + (prefix !== path.sep ? path.sep : '') + s;
});
debug('rules', rules);
var good = [];
var whitelist = []; // files that we won't check against the extension
var ignored = 0;
var watched = 0;
var usedRules = [];
var minimatchOpts = {
dot: true,
};
// enable case-insensitivity on Windows
if (utils.isWindows) {
minimatchOpts.nocase = true;
minimatchOpts.windowsPathsNoEscape = true;
}
files.forEach(function (file) {
file = path.resolve(cwd, file);
var matched = false;
for (var i = 0; i < rules.length; i++) {
if (rules[i].slice(0, 1) === '!') {
if (!minimatch(file, rules[i], minimatchOpts)) {
debug('ignored', file, 'rule:', rules[i]);
ignored++;
matched = true;
break;
}
} else {
debug('matched', file, 'rule:', rules[i]);
if (minimatch(file, rules[i], minimatchOpts)) {
watched++;
// don't repeat the output if a rule is matched
if (usedRules.indexOf(rules[i]) === -1) {
usedRules.push(rules[i]);
utils.log.detail('matched rule: ' + rules[i]);
}
// if the rule doesn't match the WATCH EVERYTHING
// but *does* match a rule that ends with *.*, then
// white list it - in that we don't run it through
// the extension check too.
if (
rules[i] !== '**' + path.sep + '*.*' &&
rules[i].slice(-3) === '*.*'
) {
whitelist.push(file);
} else if (path.basename(file) === path.basename(rules[i])) {
// if the file matches the actual rule, then it's put on whitelist
whitelist.push(file);
} else {
good.push(file);
}
matched = true;
} else {
// utils.log.detail('no match: ' + rules[i], file);
}
}
}
if (!matched) {
ignored++;
}
});
// finally check the good files against the extensions that we're monitoring
if (ext) {
if (ext.indexOf(',') === -1) {
ext = '**/*.' + ext;
} else {
ext = '**/*.{' + ext + '}';
}
good = good.filter(function (file) {
// only compare the filename to the extension test
return minimatch(path.basename(file), ext, minimatchOpts);
});
debug('good (filtered by ext)', good);
} else {
// else assume *.*
debug('good', good);
}
if (whitelist.length) debug('whitelist', whitelist);
var result = good.concat(whitelist);
if (utils.isWindows) {
// fix for windows testing - I *think* this is okay to do
result = result.map(function (file) {
return file.slice(0, 1).toLowerCase() + file.slice(1);
});
}
return {
result: result,
ignored: ignored,
watched: watched,
total: files.length,
};
}
================================================
FILE: lib/monitor/run.js
================================================
var debug = require('debug')('nodemon:run');
const statSync = require('fs').statSync;
var utils = require('../utils');
var bus = utils.bus;
var childProcess = require('child_process');
var spawn = childProcess.spawn;
var exec = childProcess.exec;
var execSync = childProcess.execSync;
var fork = childProcess.fork;
var watch = require('./watch').watch;
var config = require('../config');
var child = null; // the actual child process we spawn
var killedAfterChange = false;
var noop = () => {};
var restart = null;
var psTree = require('pstree.remy');
var path = require('path');
var signals = require('./signals');
const undefsafe = require('undefsafe');
const osRelease = parseInt(require('os').release().split('.')[0], 10);
function run(options) {
var cmd = config.command.raw;
// moved up
// we need restart function below in the global scope for run.kill
/*jshint validthis:true*/
restart = run.bind(this, options);
run.restart = restart;
// binding options with instance of run
// so that we can use it in run.kill
run.options = options;
var runCmd = !options.runOnChangeOnly || config.lastStarted !== 0;
if (runCmd) {
utils.log.status('starting `' + config.command.string + '`');
} else {
// should just watch file if command is not to be run
// had another alternate approach
// to stop process being forked/spawned in the below code
// but this approach does early exit and makes code cleaner
debug('start watch on: %s', config.options.watch);
if (config.options.watch !== false) {
watch();
return;
}
}
config.lastStarted = Date.now();
var stdio = ['pipe', 'pipe', 'pipe'];
if (config.options.stdout) {
stdio = ['pipe', process.stdout, process.stderr];
}
if (config.options.stdin === false) {
stdio = [process.stdin, process.stdout, process.stderr];
}
var sh = 'sh';
var shFlag = '-c';
const binPath = process.cwd() + '/node_modules/.bin';
const spawnOptions = {
env: Object.assign({}, options.execOptions.env, process.env, {
PATH:
binPath +
path.delimiter +
(undefsafe(options, '.execOptions.env.PATH') || process.env.PATH),
}),
stdio: stdio,
};
var executable = cmd.executable;
if (utils.isWindows) {
// if the exec includes a forward slash, reverse it for windows compat
// but *only* apply to the first command, and none of the arguments.
// ref #1251 and #1236
if (executable.indexOf('/') !== -1) {
executable = executable
.split(' ')
.map((e, i) => {
if (i === 0) {
return path.normalize(e);
}
return e;
})
.join(' ');
}
// taken from npm's cli: https://git.io/vNFD4
sh = process.env.comspec || 'cmd';
shFlag = '/d /s /c';
spawnOptions.windowsVerbatimArguments = true;
spawnOptions.windowsHide = true;
}
var args = runCmd ? utils.stringify(executable, cmd.args) : ':';
var spawnArgs = [sh, [shFlag, args], spawnOptions];
const firstArg = cmd.args[0] || '';
var inBinPath = false;
try {
inBinPath = statSync(`${binPath}/${executable}`).isFile();
} catch (e) {}
// hasStdio allows us to correctly handle stdin piping
// see: https://git.io/vNtX3
const hasStdio = utils.satisfies('>= 6.4.0 || < 5');
// forking helps with sub-process handling and tends to clean up better
// than spawning, but it should only be used under specific conditions
const shouldFork =
!config.options.spawn &&
!inBinPath &&
!(firstArg.indexOf('-') === 0) && // don't fork if there's a node exec arg
firstArg !== 'inspect' && // don't fork it's `inspect` debugger
executable === 'node' && // only fork if node
utils.version.major > 4; // only fork if node version > 4
if (shouldFork) {
// this assumes the first argument is the script and slices it out, since
// we're forking
var forkArgs = cmd.args.slice(1);
var env = utils.merge(options.execOptions.env, process.env);
stdio.push('ipc');
const forkOptions = {
env: env,
stdio: stdio,
silent: !hasStdio,
};
if (utils.isWindows) {
forkOptions.windowsHide = true;
}
child = fork(options.execOptions.script, forkArgs, forkOptions);
utils.log.detail('forking');
debug('fork', sh, shFlag, args);
} else {
utils.log.detail('spawning');
child = spawn.apply(null, spawnArgs);
debug('spawn', sh, shFlag, args);
}
if (config.required) {
var emit = {
stdout: function (data) {
bus.emit('stdout', data);
},
stderr: function (data) {
bus.emit('stderr', data);
},
};
// now work out what to bind to...
if (config.options.stdout) {
child.on('stdout', emit.stdout).on('stderr', emit.stderr);
} else {
child.stdout.on('data', emit.stdout);
child.stderr.on('data', emit.stderr);
bus.stdout = child.stdout;
bus.stderr = child.stderr;
}
if (shouldFork) {
child.on('message', function (message, sendHandle) {
bus.emit('message', message, sendHandle);
});
}
}
bus.emit('start');
utils.log.detail('child pid: ' + child.pid);
child.on('error', function (error) {
bus.emit('error', error);
if (error.code === 'ENOENT') {
utils.log.error('unable to run executable: "' + cmd.executable + '"');
process.exit(1);
} else {
utils.log.error('failed to start child process: ' + error.code);
throw error;
}
});
child.on('exit', function (code, signal) {
if (child && child.stdin) {
process.stdin.unpipe(child.stdin);
}
if (code === 127) {
utils.log.error(
'failed to start process, "' + cmd.executable + '" exec not found'
);
bus.emit('error', code);
process.exit();
}
// If the command failed with code 2, it may or may not be a syntax error
// See: http://git.io/fNOAR
// We will only assume a parse error, if the child failed quickly
if (code === 2 && Date.now() < config.lastStarted + 500) {
utils.log.error('process failed, unhandled exit code (2)');
utils.log.error('');
utils.log.error('Either the command has a syntax error,');
utils.log.error('or it is exiting with reserved code 2.');
utils.log.error('');
utils.log.error('To keep nodemon running even after a code 2,');
utils.log.error('add this to the end of your command: || exit 1');
utils.log.error('');
utils.log.error('Read more here: https://git.io/fNOAG');
utils.log.error('');
utils.log.error('nodemon will stop now so that you can fix the command.');
utils.log.error('');
bus.emit('error', code);
process.exit();
}
// In case we killed the app ourselves, set the signal thusly
if (killedAfterChange) {
killedAfterChange = false;
signal = config.signal;
}
// this is nasty, but it gives it windows support
if (utils.isWindows && signal === 'SIGTERM') {
signal = config.signal;
}
if (signal === config.signal || code === 0) {
// this was a clean exit, so emit exit, rather than crash
debug('bus.emit(exit) via ' + config.signal);
bus.emit('exit', signal);
// exit the monitor, but do it gracefully
if (signal === config.signal) {
return restart();
}
if (code === 0) {
// clean exit - wait until file change to restart
if (runCmd) {
utils.log.status('clean exit - waiting for changes before restart');
}
child = null;
}
} else {
bus.emit('crash');
// support the old syntax of `exitcrash` - 2024-12-13
if (options.exitcrash) {
options.exitCrash = true;
delete options.exitcrash;
}
if (options.exitCrash) {
utils.log.fail('app crashed');
if (!config.required) {
process.exit(1);
}
} else {
utils.log.fail(
'app crashed - waiting for file changes before' + ' starting...'
);
child = null;
}
}
if (config.options.restartable) {
// stdin needs to kick in again to be able to listen to the
// restart command
process.stdin.resume();
}
});
// moved the run.kill outside to handle both the cases
// intial start
// no start
// connect stdin to the child process (options.stdin is on by default)
if (options.stdin) {
process.stdin.resume();
// FIXME decide whether or not we need to decide the encoding
// process.stdin.setEncoding('utf8');
// swallow the stdin error if it happens
// ref: https://github.com/remy/nodemon/issues/1195
if (hasStdio) {
child.stdin.on('error', () => {});
process.stdin.pipe(child.stdin);
} else {
if (child.stdout) {
child.stdout.pipe(process.stdout);
} else {
utils.log.error(
'running an unsupported version of node ' + process.version
);
utils.log.error(
'nodemon may not work as expected - ' +
'please consider upgrading to LTS'
);
}
}
bus.once('exit', function () {
if (child && process.stdin.unpipe) {
// node > 0.8
process.stdin.unpipe(child.stdin);
}
});
}
debug('start watch on: %s', config.options.watch);
if (config.options.watch !== false) {
watch();
}
}
function waitForSubProcesses(pid, callback) {
debug('checking ps tree for pids of ' + pid);
psTree(pid, (err, pids) => {
if (!pids.length) {
return callback();
}
utils.log.status(
`still waiting for ${pids.length} sub-process${
pids.length > 2 ? 'es' : ''
} to finish...`
);
setTimeout(() => waitForSubProcesses(pid, callback), 1000);
});
}
function kill(child, signal, callback) {
if (!callback) {
callback = noop;
}
if (utils.isWindows) {
const taskKill = () => {
try {
exec('taskkill /pid ' + child.pid + ' /T /F');
} catch (e) {
utils.log.error('Could not shutdown sub process cleanly');
}
};
// We are handling a 'SIGKILL' , 'SIGUSR2' and 'SIGUSR1' POSIX signal under Windows the
// same way it is handled on a UNIX system: We are performing
// a hard shutdown without waiting for the process to clean-up.
if (
signal === 'SIGKILL' ||
osRelease < 10 ||
signal === 'SIGUSR2' ||
signal === 'SIGUSR1'
) {
debug('terminating process group by force: %s', child.pid);
// We are using the taskkill utility to terminate the whole
// process group ('/t') of the child ('/pid') by force ('/f').
// We need to end all sub processes, because the 'child'
// process in this context is actually a cmd.exe wrapper.
taskKill();
callback();
return;
}
try {
// We are using the Windows Management Instrumentation Command-line
// (wmic.exe) to resolve the sub-child process identifier, because the
// 'child' process in this context is actually a cmd.exe wrapper.
// We want to send the termination signal directly to the node process.
// The '2> nul' silences the no process found error message.
const resultBuffer = execSync(
`wmic process where (ParentProcessId=${child.pid}) get ProcessId 2> nul`
);
const result = resultBuffer.toString().match(/^[0-9]+/m);
// If there is no sub-child process we fall back to the child process.
const processId = Array.isArray(result) ? result[0] : child.pid;
debug('sending kill signal SIGINT to process: %s', processId);
// We are using the standalone 'windows-kill' executable to send the
// standard POSIX signal 'SIGINT' to the node process. This fixes #1720.
const windowsKill = path.normalize(
`${__dirname}/../../bin/windows-kill.exe`
);
// We have to detach the 'windows-kill' execution completely from this
// process group to avoid terminating the nodemon process itself.
// See: https://github.com/alirdn/windows-kill#how-it-works--limitations
//
// Therefore we are using 'start' to create a new cmd.exe context.
// The '/min' option hides the new terminal window and the '/wait'
// option lets the process wait for the command to finish.
execSync(
`start "windows-kill" /min /wait "${windowsKill}" -SIGINT ${processId}`
);
} catch (e) {
taskKill();
}
callback();
} else {
// we use psTree to kill the full subtree of nodemon, because when
// spawning processes like `coffee` under the `--debug` flag, it'll spawn
// it's own child, and that can't be killed by nodemon, so psTree gives us
// an array of PIDs that have spawned under nodemon, and we send each the
// configured signal (default: SIGUSR2) signal, which fixes #335
// note that psTree also works if `ps` is missing by looking in /proc
let sig = signal.replace('SIG', '');
psTree(child.pid, function (err, pids) {
// if ps isn't native to the OS, then we need to send the numeric value
// for the signal during the kill, `signals` is a lookup table for that.
if (!psTree.hasPS) {
sig = signals[signal];
}
// the sub processes need to be killed from smallest to largest
debug('sending kill signal to ' + pids.join(', '));
child.kill(signal);
pids.sort().forEach((pid) => exec(`kill -${sig} ${pid}`, noop));
waitForSubProcesses(child.pid, () => {
// finally kill the main user process
exec(`kill -${sig} ${child.pid}`, callback);
});
});
}
}
run.kill = function (noRestart, callback) {
// I hate code like this :( - Remy (author of said code)
if (typeof noRestart === 'function') {
callback = noRestart;
noRestart = false;
}
if (!callback) {
callback = noop;
}
if (child !== null) {
// if the stdin piping is on, we need to unpipe, but also close stdin on
// the child, otherwise linux can throw EPIPE or ECONNRESET errors.
if (run.options.stdin) {
process.stdin.unpipe(child.stdin);
}
// For the on('exit', ...) handler above the following looks like a
// crash, so we set the killedAfterChange flag if a restart is planned
if (!noRestart) {
killedAfterChange = true;
}
/* Now kill the entire subtree of processes belonging to nodemon */
var oldPid = child.pid;
if (child) {
kill(child, config.signal, function () {
// this seems to fix the 0.11.x issue with the "rs" restart command,
// though I'm unsure why. it seems like more data is streamed in to
// stdin after we close.
if (child && run.options.stdin && child.stdin && oldPid === child.pid) {
child.stdin.end();
}
callback();
});
}
} else if (!noRestart) {
// if there's no child, then we need to manually start the process
// this is because as there was no child, the child.on('exit') event
// handler doesn't exist which would normally trigger the restart.
bus.once('start', callback);
run.restart();
} else {
callback();
}
};
run.restart = noop;
bus.on('quit', function onQuit(code) {
if (code === undefined) {
code = 0;
}
// remove event listener
var exitTimer = null;
var exit = function () {
clearTimeout(exitTimer);
exit = noop; // null out in case of race condition
child = null;
if (!config.required) {
// Execute all other quit listeners.
bus.listeners('quit').forEach(function (listener) {
if (listener !== onQuit) {
listener();
}
});
process.exit(code);
} else {
bus.emit('exit');
}
};
// if we're not running already, don't bother with trying to kill
if (config.run === false) {
return exit();
}
// immediately try to stop any polling
config.run = false;
if (child) {
// give up waiting for the kids after 10 seconds
exitTimer = setTimeout(exit, 10 * 1000);
child.removeAllListeners('exit');
child.once('exit', exit);
kill(child, 'SIGINT');
} else {
exit();
}
});
bus.on('restart', function () {
// run.kill will send a SIGINT to the child process, which will cause it
// to terminate, which in turn uses the 'exit' event handler to restart
run.kill();
});
// remove the child file on exit
process.on('exit', function () {
utils.log.detail('exiting');
if (child) {
child.kill();
}
});
// because windows borks when listening for the SIG* events
if (!utils.isWindows) {
bus.once('boot', () => {
// usual suspect: ctrl+c exit
process.once('SIGINT', () => bus.emit('quit', 130));
process.once('SIGTERM', () => {
bus.emit('quit', 143);
if (child) {
child.kill('SIGTERM');
}
});
});
}
module.exports = run;
================================================
FILE: lib/monitor/signals.js
================================================
module.exports = {
SIGHUP: 1,
SIGINT: 2,
SIGQUIT: 3,
SIGILL: 4,
SIGTRAP: 5,
SIGABRT: 6,
SIGBUS: 7,
SIGFPE: 8,
SIGKILL: 9,
SIGUSR1: 10,
SIGSEGV: 11,
SIGUSR2: 12,
SIGPIPE: 13,
SIGALRM: 14,
SIGTERM: 15,
SIGSTKFLT: 16,
SIGCHLD: 17,
SIGCONT: 18,
SIGSTOP: 19,
SIGTSTP: 20,
SIGTTIN: 21,
SIGTTOU: 22,
SIGURG: 23,
SIGXCPU: 24,
SIGXFSZ: 25,
SIGVTALRM: 26,
SIGPROF: 27,
SIGWINCH: 28,
SIGIO: 29,
SIGPWR: 30,
SIGSYS: 31,
SIGRTMIN: 35,
}
================================================
FILE: lib/monitor/watch.js
================================================
module.exports.watch = watch;
module.exports.resetWatchers = resetWatchers;
var debug = require('debug')('nodemon:watch');
var debugRoot = require('debug')('nodemon');
var chokidar = require('chokidar');
var undefsafe = require('undefsafe');
var config = require('../config');
var path = require('path');
var utils = require('../utils');
var bus = utils.bus;
var match = require('./match');
var watchers = [];
var debouncedBus;
bus.on('reset', resetWatchers);
function resetWatchers() {
debugRoot('resetting watchers');
watchers.forEach(function (watcher) {
watcher.close();
});
watchers = [];
}
function watch() {
if (watchers.length) {
debug('early exit on watch, still watching (%s)', watchers.length);
return;
}
var dirs = [].slice.call(config.dirs);
debugRoot('start watch on: %s', dirs.join(', '));
const rootIgnored = config.options.ignore;
debugRoot('ignored', rootIgnored);
var watchedFiles = [];
const promise = new Promise(function (resolve) {
const dotFilePattern = /[/\\]\./;
var ignored = match.rulesToMonitor(
[], // not needed
Array.from(rootIgnored),
config
).map(pattern => pattern.slice(1));
const addDotFile = dirs.filter(dir => dir.match(dotFilePattern));
// don't ignore dotfiles if explicitly watched.
if (addDotFile.length === 0) {
ignored.push(dotFilePattern);
}
var watchOptions = {
ignorePermissionErrors: true,
ignored: ignored,
persistent: true,
usePolling: config.options.legacyWatch || false,
interval: config.options.pollingInterval,
// note to future developer: I've gone back and forth on adding `cwd`
// to the props and in some cases it fixes bugs but typically it causes
// bugs elsewhere (since nodemon is used is so many ways). the final
// decision is to *not* use it at all and work around it
// cwd: ...
};
if (utils.isWindows) {
watchOptions.disableGlobbing = true;
}
if (utils.isIBMi) {
watchOptions.usePolling = true;
}
if (process.env.TEST) {
watchOptions.useFsEvents = false;
}
var watcher = chokidar.watch(
dirs,
Object.assign({}, watchOptions, config.options.watchOptions || {})
);
watcher.ready = false;
var total = 0;
watcher.on('change', filterAndRestart);
watcher.on('unlink', filterAndRestart);
watcher.on('add', function (file) {
if (watcher.ready) {
return filterAndRestart(file);
}
watchedFiles.push(file);
bus.emit('watching', file);
debug('chokidar watching: %s', file);
});
watcher.on('ready', function () {
watchedFiles = Array.from(new Set(watchedFiles)); // ensure no dupes
total = watchedFiles.length;
watcher.ready = true;
resolve(total);
debugRoot('watch is complete');
});
watcher.on('error', function (error) {
if (error.code === 'EINVAL') {
utils.log.error(
'Internal watch failed. Likely cause: too many ' +
'files being watched (perhaps from the root of a drive?\n' +
'See https://github.com/paulmillr/chokidar/issues/229 for details'
);
} else {
utils.log.error('Internal watch failed: ' + error.message);
process.exit(1);
}
});
watchers.push(watcher);
});
return promise.catch(e => {
// this is a core error and it should break nodemon - so I have to break
// out of a promise using the setTimeout
setTimeout(() => {
throw e;
});
}).then(function () {
utils.log.detail(`watching ${watchedFiles.length} file${
watchedFiles.length === 1 ? '' : 's'}`);
return watchedFiles;
});
}
function filterAndRestart(files) {
if (!Array.isArray(files)) {
files = [files];
}
if (files.length) {
var cwd = process.cwd();
if (this.options && this.options.cwd) {
cwd = this.options.cwd;
}
utils.log.detail(
'files triggering change check: ' +
files
.map(file => {
const res = path.relative(cwd, file);
return res;
})
.join(', ')
);
// make sure the path is right and drop an empty
// filenames (sometimes on windows)
files = files.filter(Boolean).map(file => {
return path.relative(process.cwd(), path.relative(cwd, file));
});
if (utils.isWindows) {
// ensure the drive letter is in uppercase (c:\foo -> C:\foo)
files = files.map(f => {
if (f.indexOf(':') === -1) { return f; }
return f[0].toUpperCase() + f.slice(1);
});
}
debug('filterAndRestart on', files);
var matched = match(
files,
config.options.monitor,
undefsafe(config, 'options.execOptions.ext')
);
debug('matched?', JSON.stringify(matched));
// if there's no matches, then test to see if the changed file is the
// running script, if so, let's allow a restart
if (config.options.execOptions && config.options.execOptions.script) {
const script = path.resolve(config.options.execOptions.script);
if (matched.result.length === 0 && script) {
const length = script.length;
files.find(file => {
if (file.substr(-length, length) === script) {
matched = {
result: [file],
total: 1,
};
return true;
}
});
}
}
utils.log.detail(
'changes after filters (before/after): ' +
[files.length, matched.result.length].join('/')
);
// reset the last check so we're only looking at recently modified files
config.lastStarted = Date.now();
if (matched.result.length) {
if (config.options.delay > 0) {
utils.log.detail('delaying restart for ' + config.options.delay + 'ms');
if (debouncedBus === undefined) {
debouncedBus = debounce(restartBus, config.options.delay);
}
debouncedBus(matched);
} else {
return restartBus(matched);
}
}
}
}
function restartBus(matched) {
utils.log.status('restarting due to changes...');
matched.result.map(file => {
utils.log.detail(path.relative(process.cwd(), file));
});
if (config.options.verbose) {
utils.log._log('');
}
bus.emit('restart', matched.result);
}
function debounce(fn, delay) {
var timer = null;
return function () {
const context = this;
const args = arguments;
clearTimeout(timer);
timer = setTimeout(() =>fn.apply(context, args), delay);
};
}
================================================
FILE: lib/nodemon.js
================================================
var debug = require('debug')('nodemon');
var path = require('path');
var monitor = require('./monitor');
var cli = require('./cli');
var version = require('./version');
var util = require('util');
var utils = require('./utils');
var bus = utils.bus;
var help = require('./help');
/** @type {import('..').NodemonEventConfig} */
var config = require('./config');
var spawn = require('./spawn');
const defaults = require('./config/defaults')
var eventHandlers = {};
// this is fairly dirty, but theoretically sound since it's part of the
// stable module API
config.required = utils.isRequired;
/**
* @param {import('..').NodemonSettings | string} settings
* @returns {import('..').Nodemon}
*/
function nodemon(settings) {
bus.emit('boot');
nodemon.reset();
/** @type {import('..').NodemonSettings} */
let options
// allow the cli string as the argument to nodemon, and allow for
// `node nodemon -V app.js` or just `-V app.js`
if (typeof settings === 'string') {
settings = settings.trim();
if (settings.indexOf('node') !== 0) {
if (settings.indexOf('nodemon') !== 0) {
settings = 'nodemon ' + settings;
}
settings = 'node ' + settings;
}
options = cli.parse(settings);
} else options = settings;
// set the debug flag as early as possible to get all the detailed logging
if (options.verbose) {
utils.debug = true;
}
if (options.help) {
if (process.stdout.isTTY) {
process.stdout._handle.setBlocking(true); // nodejs/node#6456
}
console.log(help(options.help));
if (!config.required) {
process.exit(0);
}
}
if (options.version) {
version().then(function (v) {
console.log(v);
if (!config.required) {
process.exit(0);
}
});
return;
}
// nodemon tools like grunt-nodemon. This affects where
// the script is being run from, and will affect where
// nodemon looks for the nodemon.json files
if (options.cwd) {
// this is protection to make sure we haven't dont the chdir already...
// say like in cli/parse.js (which is where we do this once already!)
if (process.cwd() !== path.resolve(config.system.cwd, options.cwd)) {
process.chdir(options.cwd);
}
}
config.load(options, function (config) {
if (!config.options.dump && !config.options.execOptions.script &&
config.options.execOptions.exec === 'node') {
if (!config.required) {
console.log(help('usage'));
process.exit();
}
return;
}
// before we print anything, update the colour setting on logging
utils.colours = config.options.colours;
// always echo out the current version
utils.log.info(version.pinned);
const cwd = process.cwd();
if (config.options.cwd) {
utils.log.detail('process root: ' + cwd);
}
config.loaded.map(file => file.replace(cwd, '.')).forEach(file => {
utils.log.detail('reading config ' + file);
});
if (config.options.stdin && config.options.restartable) {
// allow nodemon to restart when the use types 'rs\n'
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', data => {
const str = data.toString().trim().toLowerCase();
// if the keys entered match the restartable value, then restart!
if (str === config.options.restartable) {
bus.emit('restart');
} else if (data.charCodeAt(0) === 12) { // ctrl+l
console.clear();
}
});
} else if (config.options.stdin) {
// so let's make sure we don't eat the key presses
// but also, since we're wrapping, watch out for
// special keys, like ctrl+c x 2 or '.exit' or ctrl+d or ctrl+l
var ctrlC = false;
var buffer = '';
process.stdin.on('data', function (data) {
data = data.toString();
buffer += data;
const chr = data.charCodeAt(0);
// if restartable, echo back
if (chr === 3) {
if (ctrlC) {
process.exit(0);
}
ctrlC = true;
return;
} else if (buffer === '.exit' || chr === 4) { // ctrl+d
process.exit();
} else if (chr === 13 || chr === 10) { // enter / carriage return
buffer = '';
} else if (chr === 12) { // ctrl+l
console.clear();
buffer = '';
}
ctrlC = false;
});
if (process.stdin.setRawMode) {
process.stdin.setRawMode(true);
}
}
if (config.options.restartable) {
utils.log.info('to restart at any time, enter `' +
config.options.restartable + '`');
}
if (!config.required) {
const restartSignal = config.options.signal === 'SIGUSR2' ? 'SIGHUP' : 'SIGUSR2';
process.on(restartSignal, nodemon.restart);
utils.bus.on('error', () => {
utils.log.fail((new Error().stack));
});
utils.log.detail((config.options.restartable ? 'or ' : '') + 'send ' +
restartSignal + ' to ' + process.pid + ' to restart');
}
const ignoring = config.options.monitor.map(function (rule) {
if (rule.slice(0, 1) !== '!') {
return false;
}
rule = rule.slice(1);
// don't notify of default ignores
if (defaults.ignoreRoot.indexOf(rule) !== -1) {
return false;
// return rule.slice(3).slice(0, -3);
}
if (rule.startsWith(cwd)) {
return rule.replace(cwd, '.');
}
return rule;
}).filter(Boolean).join(' ');
if (ignoring) utils.log.detail('ignoring: ' + ignoring);
utils.log.info('watching path(s): ' + config.options.monitor.map(function (rule) {
if (rule.slice(0, 1) !== '!') {
try {
rule = path.relative(process.cwd(), rule);
} catch (e) {}
return rule;
}
return false;
}).filter(Boolean).join(' '));
utils.log.info('watching extensions: ' + (config.options.execOptions.ext || '(all)'));
if (config.options.dump) {
utils.log._log('log', '--------------');
utils.log._log('log', 'node: ' + process.version);
utils.log._log('log', 'nodemon: ' + version.pinned);
utils.log._log('log', 'command: ' + process.argv.join(' '));
utils.log._log('log', 'cwd: ' + cwd);
utils.log._log('log', ['OS:', process.platform, process.arch].join(' '));
utils.log._log('log', '--------------');
utils.log._log('log', util.inspect(config, { depth: null }));
utils.log._log('log', '--------------');
if (!config.required) {
process.exit();
}
return;
}
config.run = true;
if (config.options.stdout === false) {
nodemon.on('start', function () {
nodemon.stdout = bus.stdout;
nodemon.stderr = bus.stderr;
bus.emit('readable');
});
}
if (config.options.events && Object.keys(config.options.events).length) {
Object.keys(config.options.events).forEach(function (key) {
utils.log.detail('bind ' + key + ' -> `' +
config.options.events[key] + '`');
nodemon.on(key, function () {
if (config.options && config.options.events) {
spawn(config.options.events[key], config,
[].slice.apply(arguments));
}
});
});
}
monitor.run(config.options);
});
return nodemon;
}
nodemon.restart = function () {
utils.log.status('restarting child process');
bus.emit('restart');
return nodemon;
};
nodemon.addListener = nodemon.on = function (event, handler) {
if (!eventHandlers[event]) { eventHandlers[event] = []; }
eventHandlers[event].push(handler);
bus.on(event, handler);
return nodemon;
};
nodemon.once = function (event, handler) {
if (!eventHandlers[event]) { eventHandlers[event] = []; }
eventHandlers[event].push(handler);
bus.once(event, function () {
debug('bus.once(%s)', event);
eventHandlers[event].splice(eventHandlers[event].indexOf(handler), 1);
handler.apply(this, arguments);
});
return nodemon;
};
nodemon.emit = function () {
bus.emit.apply(bus, [].slice.call(arguments));
return nodemon;
};
nodemon.removeAllListeners = function (event) {
// unbind only the `nodemon.on` event handlers
Object.keys(eventHandlers).filter(function (e) {
return event ? e === event : true;
}).forEach(function (event) {
eventHandlers[event].forEach(function (handler) {
bus.removeListener(event, handler);
eventHandlers[event].splice(eventHandlers[event].indexOf(handler), 1);
});
});
return nodemon;
};
nodemon.reset = function (done) {
bus.emit('reset', done);
};
bus.on('reset', function (done) {
debug('reset');
nodemon.removeAllListeners();
monitor.run.kill(true, function () {
utils.reset();
config.reset();
config.run = false;
if (done) {
done();
}
});
});
// expose the full config
nodemon.config = config;
module.exports = nodemon;
================================================
FILE: lib/rules/add.js
================================================
'use strict';
var utils = require('../utils');
// internal
var reEscComments = /\\#/g;
// note that '^^' is used in place of escaped comments
var reUnescapeComments = /\^\^/g;
var reComments = /#.*$/;
var reEscapeChars = /[.|\-[\]()\\]/g;
var reAsterisk = /\*/g;
module.exports = add;
/**
* Converts file patterns or regular expressions to nodemon
* compatible RegExp matching rules. Note: the `rules` argument
* object is modified to include the new rule and new RegExp
*
* ### Example:
*
* var rules = { watch: [], ignore: [] };
* add(rules, 'watch', '*.js');
* add(rules, 'ignore', '/public/');
* add(rules, 'watch', ':(\d)*\.js'); // note: string based regexp
* add(rules, 'watch', /\d*\.js/);
*
* @param {Object} rules containing `watch` and `ignore`. Also updated during
* execution
* @param {String} which must be either "watch" or "ignore"
* @param {String|RegExp} rule the actual rule.
*/
function add(rules, which, rule) {
if (!{ ignore: 1, watch: 1}[which]) {
throw new Error('rules/index.js#add requires "ignore" or "watch" as the ' +
'first argument');
}
if (Array.isArray(rule)) {
rule.forEach(function (rule) {
add(rules, which, rule);
});
return;
}
// support the rule being a RegExp, but reformat it to
// the custom :<regexp> format that we're working with.
if (rule instanceof RegExp) {
// rule = ':' + rule.toString().replace(/^\/(.*?)\/$/g, '$1');
utils.log.error('RegExp format no longer supported, but globs are.');
return;
}
// remove comments and trim lines
// this mess of replace methods is escaping "\#" to allow for emacs temp files
// first up strip comments and remove blank head or tails
rule = (rule || '').replace(reEscComments, '^^')
.replace(reComments, '')
.replace(reUnescapeComments, '#').trim();
var regexp = false;
if (typeof rule === 'string' && rule.substring(0, 1) === ':') {
rule = rule.substring(1);
utils.log.error('RegExp no longer supported: ' + rule);
regexp = true;
} else if (rule.length === 0) {
// blank line (or it was a comment)
return;
}
if (regexp) {
// rules[which].push(rule);
} else {
// rule = rule.replace(reEscapeChars, '\\$&')
// .replace(reAsterisk, '.*');
rules[which].push(rule);
// compile a regexp of all the rules for this ignore or watch
var re = rules[which].map(function (rule) {
return rule.replace(reEscapeChars, '\\$&')
.replace(reAsterisk, '.*');
}).join('|');
// used for the directory matching
rules[which].re = new RegExp(re);
}
}
================================================
FILE: lib/rules/index.js
================================================
'use strict';
var utils = require('../utils');
var add = require('./add');
var parse = require('./parse');
// exported
var rules = { ignore: [], watch: [] };
/**
* Loads a nodemon config file and populates the ignore
* and watch rules with it's contents, and calls callback
* with the new rules
*
* @param {String} filename
* @param {Function} callback
*/
function load(filename, callback) {
parse(filename, function (err, result) {
if (err) {
// we should have bombed already, but
utils.log.error(err);
callback(err);
}
if (result.raw) {
result.raw.forEach(add.bind(null, rules, 'ignore'));
} else {
result.ignore.forEach(add.bind(null, rules, 'ignore'));
result.watch.forEach(add.bind(null, rules, 'watch'));
}
callback(null, rules);
});
}
module.exports = {
reset: function () { // just used for testing
rules.ignore.length = rules.watch.length = 0;
delete rules.ignore.re;
delete rules.watch.re;
},
load: load,
ignore: {
test: add.bind(null, rules, 'ignore'),
add: add.bind(null, rules, 'ignore'),
},
watch: {
test: add.bind(null, rules, 'watch'),
add: add.bind(null, rules, 'watch'),
},
add: add.bind(null, rules),
rules: rules,
};
================================================
FILE: lib/rules/parse.js
================================================
'use strict';
var fs = require('fs');
/**
* Parse the nodemon config file, supporting both old style
* plain text config file, and JSON version of the config
*
* @param {String} filename
* @param {Function} callback
*/
function parse(filename, callback) {
var rules = {
ignore: [],
watch: [],
};
fs.readFile(filename, 'utf8', function (err, content) {
if (err) {
return callback(err);
}
var json = null;
try {
json = JSON.parse(content);
} catch (e) {}
if (json !== null) {
rules = {
ignore: json.ignore || [],
watch: json.watch || [],
};
return callback(null, rules);
}
// otherwise return the raw file
return callback(null, { raw: content.split(/\n/) });
});
}
module.exports = parse;
================================================
FILE: lib/spawn.js
================================================
const path = require('path');
const utils = require('./utils');
const merge = utils.merge;
const bus = utils.bus;
const spawn = require('child_process').spawn;
module.exports = function spawnCommand(command, config, eventArgs) {
var stdio = ['pipe', 'pipe', 'pipe'];
if (config.options.stdout) {
stdio = ['pipe', process.stdout, process.stderr];
}
const env = merge(process.env, { FILENAME: eventArgs[0] });
var sh = 'sh';
var shFlag = '-c';
var spawnOptions = {
env: merge(config.options.execOptions.env, env),
stdio: stdio,
};
if (!Array.isArray(command)) {
command = [command];
}
if (utils.isWindows) {
// if the exec includes a forward slash, reverse it for windows compat
// but *only* apply to the first command, and none of the arguments.
// ref #1251 and #1236
command = command.map(executable => {
if (executable.indexOf('/') === -1) {
return executable;
}
return executable.split(' ').map((e, i) => {
if (i === 0) {
return path.normalize(e);
}
return e;
}).join(' ');
});
// taken from npm's cli: https://git.io/vNFD4
sh = process.env.comspec || 'cmd';
shFlag = '/d /s /c';
spawnOptions.windowsVerbatimArguments = true;
spawnOptions.windowsHide = true;
}
const args = command.join(' ');
const child = spawn(sh, [shFlag, args], spawnOptions);
if (config.required) {
var emit = {
stdout: function (data) {
bus.emit('stdout', data);
},
stderr: function (data) {
bus.emit('stderr', data);
},
};
// now work out what to bind to...
if (config.options.stdout) {
child.on('stdout', emit.stdout).on('stderr', emit.stderr);
} else {
child.stdout.on('data', emit.stdout);
child.stderr.on('data', emit.stderr);
bus.stdout = child.stdout;
bus.stderr = child.stderr;
}
}
};
================================================
FILE: lib/utils/bus.js
================================================
var events = require('events');
var debug = require('debug')('nodemon');
var util = require('util');
var Bus = function () {
events.EventEmitter.call(this);
};
util.inherits(Bus, events.EventEmitter);
var bus = new Bus();
// /*
var collected = {};
bus.on('newListener', function (event) {
debug('bus new listener: %s (%s)', event, bus.listeners(event).length);
if (!collected[event]) {
collected[event] = true;
bus.on(event, function () {
debug('bus emit: %s', event);
});
}
});
// */
// proxy process messages (if forked) to the bus
process.on('message', function (event) {
debug('process.message(%s)', event);
bus.emit(event);
});
var emit = bus.emit;
// if nodemon was spawned via a fork, allow upstream communication
// via process.send
if (process.send) {
bus.emit = function (event, data) {
process.send({ type: event, data: data });
emit.apply(bus, arguments);
};
}
module.exports = bus;
================================================
FILE: lib/utils/clone.js
================================================
module.exports = clone;
// via http://stackoverflow.com/a/728694/22617
function clone(obj) {
// Handle the 3 simple types, and null or undefined
if (null === obj || 'object' !== typeof obj) {
return obj;
}
var copy;
// Handle Date
if (obj instanceof Date) {
copy = new Date();
copy.setTime(obj.getTime());
return copy;
}
// Handle Array
if (obj instanceof Array) {
copy = [];
for (var i = 0, len = obj.length; i < len; i++) {
copy[i] = clone(obj[i]);
}
return copy;
}
// Handle Object
if (obj instanceof Object) {
copy = {};
for (var attr in obj) {
if (obj.hasOwnProperty && obj.hasOwnProperty(attr)) {
copy[attr] = clone(obj[attr]);
}
}
return copy;
}
throw new Error('Unable to copy obj! Its type isn\'t supported.');
}
================================================
FILE: lib/utils/colour.js
================================================
/**
* Encodes a string in a colour: red, yellow or green
* @param {String} c colour to highlight in
* @param {String} str the string to encode
* @return {String} coloured string for terminal printing
*/
function colour(c, str) {
return (colour[c] || colour.black) + str + colour.black;
}
function strip(str) {
re.lastIndex = 0; // reset position
return str.replace(re, '');
}
colour.red = '\x1B[31m';
colour.yellow = '\x1B[33m';
colour.green = '\x1B[32m';
colour.black = '\x1B[39m';
var reStr = Object.keys(colour).map(key => colour[key]).join('|');
var re = new RegExp(('(' + reStr + ')').replace(/\[/g, '\\['), 'g');
colour.strip = strip;
module.exports = colour;
================================================
FILE: lib/utils/index.js
================================================
var noop = function () { };
var path = require('path');
const semver = require('semver');
var version = process.versions.node.split('.') || [null, null, null];
var utils = (module.exports = {
semver: semver,
satisfies: test => semver.satisfies(process.versions.node, test),
version: {
major: parseInt(version[0] || 0, 10),
minor: parseInt(version[1] || 0, 10),
patch: parseInt(version[2] || 0, 10),
},
clone: require('./clone'),
merge: require('./merge'),
bus: require('./bus'),
isWindows: process.platform === 'win32',
isMac: process.platform === 'darwin',
isLinux: process.platform === 'linux',
isIBMi: require('os').type() === 'OS400',
isRequired: (function () {
var p = module.parent;
while (p) {
// in electron.js engine it happens
if (!p.filename) {
return true;
}
if (p.filename.indexOf('bin' + path.sep + 'nodemon.js') !== -1) {
return false;
}
p = p.parent;
}
return true;
})(),
home: process.env.HOME || process.env.HOMEPATH,
quiet: function () {
// nukes the logging
if (!this.debug) {
for (var method in utils.log) {
if (typeof utils.log[method] === 'function') {
utils.log[method] = noop;
}
}
}
},
reset: function () {
if (!this.debug) {
for (var method in utils.log) {
if (typeof utils.log[method] === 'function') {
delete utils.log[method];
}
}
}
this.debug = false;
},
regexpToText: function (t) {
return t
.replace(/\.\*\\./g, '*.')
.replace(/\\{2}/g, '^^')
.replace(/\\/g, '')
.replace(/\^\^/g, '\\');
},
stringify: function (exec, args) {
// serializes an executable string and array of arguments into a string
args = args || [];
return [exec]
.concat(
args.map(function (arg) {
// if an argument contains a space, we want to show it with quotes
// around it to indicate that it is a single argument
if (arg.length > 0 && arg.indexOf(' ') === -1) {
return arg;
}
// this should correctly escape nested quotes
return JSON.stringify(arg);
})
)
.join(' ')
.trim();
},
});
utils.log = require('./log')(utils.isRequired);
Object.defineProperty(utils, 'debug', {
set: function (value) {
this.log.debug = value;
},
get: function () {
return this.log.debug;
},
});
Object.defineProperty(utils, 'colours', {
set: function (value) {
this.log.useColours = value;
},
get: function () {
return this.log.useColours;
},
});
================================================
FILE: lib/utils/log.js
================================================
var colour = require('./colour');
var bus = require('./bus');
var required = false;
var useColours = true;
var coding = {
log: 'black',
info: 'yellow',
status: 'green',
detail: 'yellow',
fail: 'red',
error: 'red',
};
function log(type, text) {
var msg = '[nodemon] ' + (text || '');
if (useColours) {
msg = colour(coding[type], msg);
}
// always push the message through our bus, using nextTick
// to help testing and get _out of_ promises.
process.nextTick(() => {
bus.emit('log', { type: type, message: text, colour: msg });
});
// but if we're running on the command line, also echo out
// question: should we actually just consume our own events?
if (!required) {
if (type === 'error') {
console.error(msg);
} else {
console.log(msg || '');
}
}
}
var Logger = function (r) {
if (!(this instanceof Logger)) {
return new Logger(r);
}
this.required(r);
return this;
};
Object.keys(coding).forEach(function (type) {
Logger.prototype[type] = log.bind(null, type);
});
// detail is for messages that are turned on during debug
Logger.prototype.detail = function (msg) {
if (this.debug) {
log('detail', msg);
}
};
Logger.prototype.required = function (val) {
required = val;
};
Logger.prototype.debug = false;
Logger.prototype._log = function (type, msg) {
if (required) {
bus.emit('log', { type: type, message: msg || '', colour: msg || '' });
} else if (type === 'error') {
console.error(msg);
} else {
console.log(msg || '');
}
};
Object.defineProperty(Logger.prototype, 'useColours', {
set: function (val) {
useColours = val;
},
get: function () {
return useColours;
},
});
module.exports = Logger;
================================================
FILE: lib/utils/merge.js
================================================
var clone = require('./clone');
module.exports = merge;
function typesMatch(a, b) {
return (typeof a === typeof b) && (Array.isArray(a) === Array.isArray(b));
}
/**
* A deep merge of the source based on the target.
* @param {Object} source [description]
* @param {Object} target [description]
* @return {Object} [description]
*/
function merge(source, target, result) {
if (result === undefined) {
result = clone(source);
}
// merge missing values from the target to the source
Object.getOwnPropertyNames(target).forEach(function (key) {
if (source[key] === undefined) {
result[key] = target[key];
}
});
Object.getOwnPropertyNames(source).forEach(function (key) {
var value = source[key];
if (target[key] && typesMatch(value, target[key])) {
// merge empty values
if (value === '') {
result[key] = target[key];
}
if (Array.isArray(value)) {
if (value.length === 0 && target[key].length) {
result[key] = target[key].slice(0);
}
} else if (typeof value === 'object') {
result[key] = merge(value, target[key]);
}
}
});
return result;
}
================================================
FILE: lib/version.js
================================================
module.exports = version;
module.exports.pin = pin;
var fs = require('fs');
var path = require('path');
var exec = require('child_process').exec;
var root = null;
function pin() {
return version().then(function (v) {
version.pinned = v;
});
}
function version(callback) {
// first find the package.json as this will be our root
var promise = findPackage(path.dirname(module.parent.filename))
.then(function (dir) {
// now try to load the package
var v = require(path.resolve(dir, 'package.json')).version;
if (v && v !== '0.0.0-development') {
return v;
}
root = dir;
// else we're in development, give the commit out
// get the last commit and whether the working dir is dirty
var promises = [
branch().catch(function () { return 'master'; }),
commit().catch(function () { return '<none>'; }),
dirty().catch(function () { return 0; }),
];
// use the cached result as the export
return Promise.all(promises).then(function (res) {
var branch = res[0];
var commit = res[1];
var dirtyCount = parseInt(res[2], 10);
var curr = branch + ': ' + commit;
if (dirtyCount !== 0) {
curr += ' (' + dirtyCount + ' dirty files)';
}
return curr;
});
}).catch(function (error) {
console.log(error.stack);
throw error;
});
if (callback) {
promise.then(function (res) {
callback(null, res);
}, callback);
}
return promise;
}
function findPackage(dir) {
if (dir === '/') {
return Promise.reject(new Error('package not found'));
}
return new Promise(function (resolve) {
fs.stat(path.resolve(dir, 'package.json'), function (error, exists) {
if (error || !exists) {
return resolve(findPackage(path.resolve(dir, '..')));
}
resolve(dir);
});
});
}
function command(cmd) {
return new Promise(function (resolve, reject) {
exec(cmd, { cwd: root }, function (err, stdout, stderr) {
var error = stderr.trim();
if (error) {
return reject(new Error(error));
}
resolve(stdout.split('\n').join(''));
});
});
}
function commit() {
return command('git rev-parse HEAD');
}
function branch() {
return command('git rev-parse --abbrev-ref HEAD');
}
function dirty() {
return command('expr $(git status --porcelain 2>/dev/null| ' +
'egrep "^(M| M)" | wc -l)');
}
================================================
FILE: package.json
================================================
{
"name": "nodemon",
"homepage": "https://nodemon.io",
"author": {
"name": "Remy Sharp",
"url": "https://github.com/remy"
},
"bin": {
"nodemon": "./bin/nodemon.js"
},
"engines": {
"node": ">=10"
},
"repository": {
"type": "git",
"url": "https://github.com/remy/nodemon.git"
},
"description": "Simple monitor script for use during development of a Node.js app.",
"keywords": [
"cli",
"monitor",
"monitor",
"development",
"restart",
"autoload",
"reload",
"terminal"
],
"license": "MIT",
"types": "./index.d.ts",
"main": "./lib/nodemon",
"scripts": {
"commitmsg": "commitlint -e",
"coverage": "istanbul cover _mocha -- --timeout 30000 --ui bdd --reporter list test/**/*.test.js",
"lint": "eslint lib/**/*.js",
"test": "npm run lint && npm run spec",
"spec": "for FILE in test/**/*.test.js; do echo $FILE; TEST=1 mocha --exit --timeout 30000 $FILE; if [ $? -ne 0 ]; then exit 1; fi; sleep 1; done",
"postspec": "npm run clean",
"clean": "rm -rf test/fixtures/test*.js test/fixtures/test*.md",
"web": "node web",
"semantic-release": "semantic-release",
"prepush": "npm run lint",
"killall": "ps auxww | grep node | grep -v grep | awk '{ print $2 }' | xargs kill -9"
},
"devDependencies": {
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"async": "1.4.2",
"coffee-script": "~1.7.1",
"eslint": "^7.32.0",
"husky": "^7.0.4",
"mocha": "^2.5.3",
"nyc": "^15.1.0",
"proxyquire": "^1.8.0",
"semantic-release": "^25.0.0",
"should": "~4.0.0"
},
"dependencies": {
"chokidar": "^3.5.2",
"debug": "^4",
"ignore-by-default": "^1.0.1",
"minimatch": "^10.2.1",
"pstree.remy": "^1.1.8",
"semver": "^7.5.3",
"simple-update-notifier": "^2.0.0",
"supports-color": "^5.5.0",
"touch": "^3.1.0",
"undefsafe": "^2.0.5"
},
"version": "0.0.0-development",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/nodemon"
},
"publishConfig": {
"provenance": true
}
}
================================================
FILE: test/cli/exec.test.js
================================================
'use strict';
/*global describe:true, it: true */
const path = require('path');
const exec = require('../../lib/config/exec');
const expandScript = exec.expandScript;
const command = require('../../lib/config/command');
const assert = require('assert');
const utils = require('../../lib/utils');
function toCmd(options) {
var cmd = command({
script: options.script || 'app.js',
execOptions: options,
});
return {
cmd: cmd,
string: utils.stringify(cmd.executable, cmd.args),
};
}
describe('expandScript', () => {
var pwd = process.cwd();
afterEach(function () {
process.chdir(pwd);
});
beforeEach(function () {
// move to the fixtures directory to allow for config loading
process.chdir(path.resolve(pwd, 'test/fixtures'));
});
it('should expand app.js', () => {
const script = expandScript('app');
assert.equal(script, 'app.js', script);
});
it('should expand hello.py', () => {
const script = expandScript('hello', '.py');
assert.equal(script, 'hello.py', script);
});
it('should ignore foo.js', () => {
const script = expandScript('foo', '.js');
assert.equal(script, 'foo', script);
});
});
describe('nodemon exec', function () {
var pwd = process.cwd();
afterEach(function () {
process.chdir(pwd);
});
beforeEach(function () {
// move to the fixtures directory to allow for config loading
process.chdir(path.resolve(pwd, 'test/fixtures'));
});
it('should default to node', function () {
var options = exec({ script: 'index.js' });
var cmd = toCmd(options);
assert.equal(options.exec, 'node', 'exec is node');
assert.equal(options.ext, 'js,mjs,cjs,json');
assert.equal(cmd.string, 'node index.js', cmd.string);
});
it('should support --debug', function () {
var options = exec({ script: 'app.js', nodeArgs: ['--debug'] });
var cmd = toCmd(options);
assert(cmd.string === 'node --debug app.js', cmd.string);
assert(options.ext.indexOf('js') !== -1, 'extension watched is .js');
});
it('should support --debug=XXXX', function () {
var options = exec({ script: 'app.js', nodeArgs: ['--debug=9999'] });
var cmd = toCmd(options);
assert(cmd.string === 'node --debug=9999 app.js', cmd.string);
assert(options.exec === 'node');
assert(options.ext.indexOf('js') !== -1);
});
it('should support multiple extensions', function () {
var options = exec({ script: 'app.js', ext: 'js, pug, hbs' });
var cmd = toCmd(options);
assert(cmd.string === 'node app.js', cmd.string);
assert(options.ext.indexOf('pug') !== -1, 'comma separated string');
options = exec({ script: 'app.js', ext: 'js|pug|hbs' });
assert(options.exec === 'node');
assert(options.ext.indexOf('pug') !== -1, 'pipe separated string');
});
it('should support watching all extensions', function () {
var options = exec({ script: 'app.js', ext: '' });
assert.equal(
options.ext,
'',
'does not set default extensions when empty extension requested'
);
options = exec({ script: 'app.js', ext: '.' });
assert.equal(options.ext, '', 'treats `.` as wildcard extension');
options = exec({ script: 'app.js', ext: '*' });
assert.equal(options.ext, '', 'treats `*` as wildcard extension');
options = exec({ script: 'app.coffee', exec: 'coffee', ext: '' });
assert.equal(
options.ext,
'',
'does not set default extensions when empty extension requested'
);
});
it('should replace {{filename}}', function () {
var options = exec({
script: 'app.js',
exec: 'node {{filename}}.tmp --somethingElse',
});
var cmd = toCmd(options);
assert(cmd.string === 'node app.js.tmp --somethingElse', cmd.string);
});
it('should not split on spaces in {{filename}}', function () {
var options = exec({
script: 'my app.js',
exec: 'node {{filename}}.tmp --somethingElse',
});
var cmd = toCmd(options);
// var cmd = command({ execOptions: options });
assert(cmd.string === 'node my app.js.tmp --somethingElse', cmd.string);
});
it('should support extension maps', function () {
var options = exec(
{ script: 'template.pug' },
{ pug: 'pug {{filename}} --out /tmp' }
);
var cmd = toCmd(options);
assert(cmd.string === 'pug template.pug --out /tmp', cmd.string);
});
it('should support input from argv#parse', function () {
var parse = require('../../lib/cli/parse');
parse(
'node /usr/local/bin/nodemon.js --debug -e js,pug,hbs app.js'.split(' ')
);
});
it('should use coffeescript on .coffee', function () {
var options = exec({ script: 'index.coffee' });
assert(
options.exec.indexOf('coffee') === 0,
'using coffeescript to execute'
);
assert(options.ext.indexOf('coffee') !== -1);
});
it('should support coffeescript in debug mode', function () {
var options = exec({ script: 'app.coffee', nodeArgs: ['--debug'] });
assert(
options.exec.indexOf('coffee') === 0,
'using coffeescript to execute'
);
assert(options.execArgs[1].indexOf('--debug') !== -1);
assert(options.ext.indexOf('coffee') !== -1);
});
it('should support custom execs', function () {
var options = exec({ script: 'app.py', exec: 'python' });
assert(options.exec === 'python');
assert(options.ext.indexOf('py') !== -1);
});
it('should support custom executables with arguments', function () {
var options = exec({ script: 'app.py', exec: 'python --debug' });
var cmd = toCmd(options);
assert(cmd.string === 'python --debug app.py', cmd.string);
assert(options.ext.indexOf('py') !== -1);
});
it('should support an array of exec arguments', function () {
var options = exec({ script: 'app.js', exec: ['/path to node', '-v'] });
assert(options.exec === '/path to node', options.exec);
assert(options.execArgs.length === 1, options.execArgs.length);
assert(options.execArgs[0] === '-v', options.execArgs[0]);
});
it('should support non-english filenames', function () {
var parse = require('../../lib/cli/parse');
var options = parse('node nodemon.js -e ζ ./server.js "$@"'.split(' '));
var res = exec(options);
assert(res.ext === 'ζ', 'exec did not bail');
});
it('should support multi-level file extensions', function () {
var options = exec({ ext: '.ts.d,js md' });
assert(options.ext.indexOf('ts.d') !== -1);
assert(options.ext.indexOf('js') !== -1);
assert(options.ext.indexOf('md') !== -1);
});
it('should support single-level file extensions', function () {
var options = exec({ ext: '.js, pug' });
assert(options.ext.indexOf('js') !== -1);
assert(options.ext.indexOf('pug') !== -1);
});
it('should expand app to app.js', function () {
var options = exec({ script: 'app' });
var cmd = toCmd(options);
assert(cmd.string === 'node app.js', cmd.string);
options = exec({ script: 'app', ext: '' });
cmd = toCmd(options);
assert(cmd.string === 'node app.js', cmd.string);
});
it('should expand based on custom extensions to hello.py', function () {
var options = exec({ script: 'hello', ext: '.py', exec: 'python' });
var cmd = toCmd(options);
assert(cmd.string === 'python hello.py', cmd.string);
});
it('should expand based on custom extensions to app.js (js,jsx,mjs)', function () {
var options = exec({ script: 'app', ext: 'js,jsx,mjs' });
var cmd = toCmd(options);
assert(cmd.string === 'node app.js', cmd.string);
});
it('should not expand index to non-existant index.js', function () {
var options = exec({ script: 'index' });
var cmd = toCmd(options);
assert(cmd.string === 'node index', cmd.string);
});
});
================================================
FILE: test/cli/parse.test.js
================================================
'use strict';
/*global describe:true, it: true */
var cli = require('../../lib/cli/'),
exec = require('../../lib/config/exec'),
pkg = require('../../package'),
assert = require('assert'),
command = require('../../lib/config/command'),
utils = require('../../lib/utils');
const mutateExecOptions = require('../../lib/config/load').mutateExecOptions;
function asCLI(cmd) {
return ('node nodemon ' + (cmd || '')).trim();
}
function parse(cmd) {
var parsed = cli.parse(cmd);
// mirrored based on /lib/config/load.js:36
parsed.execOptions = exec({
script: parsed.script,
exec: parsed.exec,
args: parsed.args,
scriptPosition: parsed.scriptPosition,
nodeArgs: parsed.nodeArgs,
ext: parsed.ext,
env: parsed.env
});
return parsed;
return mutateExecOptions(cli.parse(cmd));
}
function commandToString(command) {
return utils.stringify(command.executable, command.args);
}
describe('nodemon CLI parser', function () {
it('should support --debug with script detect via package', function () {
var cwd = process.cwd();
process.chdir('test/fixtures/packages/express4');
var settings = parse(asCLI('--debug'));
var cmd = commandToString(command(settings));
process.chdir(cwd);
assert.equal(cmd, 'NODE_ENV=development node ./bin/www --debug');
});
it('should replace {{filename}}', function () {
var settings = parse(asCLI('test/fixtures/app.js --exec "node {{filename}}.tmp" --somethingElse'));
var cmd = commandToString(command(settings));
assert(cmd === 'node test/fixtures/app.js.tmp --somethingElse', cmd);
});
it('should replace {{filename}} multiple times', function () {
var settings = parse(asCLI('test/fixtures/app.js --exec "node {{filename}}.tmp {{filename}}.tmp" --somethingElse'));
var cmd = commandToString(command(settings));
assert(cmd === 'node test/fixtures/app.js.tmp test/fixtures/app.js.tmp --somethingElse', cmd);
});
it('should parse the help examples #1', function () {
var settings = parse(asCLI('test/fixtures/app.js')),
cmd = commandToString(command(settings));
assert(cmd === 'node test/fixtures/app.js', 'node test/fixtures/app.js: ' + cmd);
});
it('should parse the help examples #2', function () {
var settings = parse(asCLI('-w ../lib test/fixtures/app.js apparg1 apparg2')),
cmd = commandToString(command(settings));
assert.deepEqual(settings.watch, ['../lib'], 'watching ../lib: ' + settings.watch);
assert.deepEqual(settings.execOptions.args, ['apparg1', 'apparg2'], 'args are corr ' + settings.execOptions.args);
assert(cmd === 'node test/fixtures/app.js apparg1 apparg2', 'command is ' + cmd);
});
it('should parse the help examples #3', function () {
var settings = parse(asCLI('--exec python app.py')),
cmd = commandToString(command(settings));
assert(cmd === 'python app.py', 'command is ' + cmd);
assert(settings.execOptions.exec === 'python', 'exec is python');
});
it('should parse the help examples #4', function () {
var settings = parse(asCLI('--exec "make build" -e "styl hbs"')),
cmd = commandToString(command(settings));
assert(cmd === 'make build', 'command is ' + cmd);
assert.deepEqual(settings.execOptions.ext.split(','), ['styl', 'hbs'], 'correct extensions being watched: ' + settings.execOptions.ext);
});
it('should parse the help examples #5', function () {
var settings = parse(asCLI('test/fixtures/app.js -- -L')),
cmd = commandToString(command(settings));
assert(cmd === 'node test/fixtures/app.js -L', 'command is ' + cmd);
});
it('should put the script at the end if found in package.main', function () {
var pwd = process.cwd();
process.chdir('test/fixtures'); // allows us to load text/fixtures/package.json
var settings = parse(asCLI('--harmony')),
cmd = commandToString(command(settings));
process.chdir(pwd);
assert(cmd === 'node --harmony app.js', 'command is ' + cmd);
});
it('should support default express4 format', function () {
var pwd = process.cwd();
process.chdir('test/fixtures/packages/express4'); // allows us to load text/fixtures/package.json
var settings = parse(asCLI()),
cmd = commandToString(command(settings));
process.chdir(pwd);
assert.equal(cmd, 'NODE_ENV=development node ./bin/www', 'command is "' + cmd + '"');
});
it('should support spaces', function () {
var pwd = process.cwd();
process.chdir('test/fixtures/');
var settings = parse(asCLI('--exec \'"app with spaces.js" foo\''));
var cmd = commandToString(command(settings));
process.chdir(pwd);
assert(cmd === '"app with spaces.js" foo', cmd);
});
it('should support quotes around arguments', function () {
var settings = parse(asCLI('--watch "foo bar"'));
assert(settings.watch[0] === 'foo bar');
});
it('should keep eating arguments that are for nodemon after the script.js', function () {
var settings = parse(asCLI('--watch "foo bar" test/fixtures/app.js -V --scriptOpt1 -- -V'));
assert.deepEqual(settings.execOptions.args, ['--scriptOpt1', '-V'], 'script args are: ' + settings.execOptions.args.join(' '));
assert(settings.verbose === true, 'verbose');
assert(settings.watch[0] === 'foo bar', 'watching "foo bar" dir');
});
it('should allow -- to appear anywhere, and still find user script', function () {
var settings = parse(asCLI('test/fixtures/app.js -- -V'));
assert(!settings.verbose, '-V arg was passed to script, not nodemon');
assert.deepEqual(settings.execOptions.args, ['-V'], 'script passed -V via --');
settings = parse(asCLI('-- test/fixtures/app.js -V'));
assert.deepEqual(settings.execOptions.args, ['-V'], 'leading -- finds script');
settings = parse(asCLI('test/fixtures/app.js -V --'));
assert.deepEqual(settings.execOptions.args, [], '-- is ignored');
assert(settings.verbose, '-V was passed to nodemon');
});
it('should support arguments from the cli', function () {
var settings = parse(['node', 'nodemon', '--watch', 'foo bar']);
assert(settings.watch[0] === 'foo bar');
});
it('should support stand alone `nodemon` command', function () {
var settings = parse(asCLI(''));
assert(settings.execOptions.script === pkg.main + '.js', `${settings.execOptions.script} === ${pkg.main}`);
});
it('should put --debug in the right place with coffescript', function () {
var settings = parse(asCLI('--debug test/fixtures/app.coffee'));
// using indexOf instead of === because on windows
// coffee is coffee.cmd - so we check for a partial match
assert(commandToString(command(settings)).indexOf('--nodejs --debug test/fixtures/app.coffee') !== -1);
assert(settings.execOptions.exec.indexOf('coffee') === 0, 'executable is CoffeeScript');
});
it('should support period path', function () {
var settings = parse(asCLI('.'));
assert(commandToString(command(settings)) === 'node .');
});
it('should parse `nodemon lib/index.js`', function () {
var settings = parse(asCLI('lib/index.js'));
assert(settings.script === 'lib/index.js');
});
it('should parse `nodemon --config my/.nodemon.json server.js`', function () {
var settings = parse(asCLI('--config my/.nodemon.json test/fixtures/app.js'));
assert(settings.configFile === 'my/.nodemon.json');
assert(settings.script === 'test/fixtures/app.js');
});
it('should parse `nodemon test/fixtures/app.coffee`', function () {
var settings = parse(asCLI('test/fixtures/app.coffee'));
assert(settings.script === 'test/fixtures/app.coffee');
assert(settings.execOptions.exec.indexOf('coffee') === 0, 'executable is CoffeeScript');
});
it('should parse `nodemon --watch src/ -e js,coffee test/fixtures/app.js`', function () {
var settings = parse(asCLI('--watch src/ -e js,coffee test/fixtures/app.js'));
assert(settings.script === 'test/fixtures/app.js');
assert(settings.execOptions.exec === 'node');
});
it('should pass --debug to node', function () {
var settings = parse(asCLI('--debug test/fixtures/app.js'));
assert(settings.script === 'test/fixtures/app.js');
assert(settings.execOptions.exec === 'node');
assert(commandToString(command(settings)).indexOf('--debug') !== -1);
});
it('should pass --harmony to node', function () {
var settings = parse(asCLI('--harmony test/fixtures/app.js'));
assert(settings.script === 'test/fixtures/app.js');
assert(settings.execOptions.exec === 'node');
assert(commandToString(command(settings)).indexOf('--harmony') !== -1);
});
});
describe('nodemon argument parser', function () {
it('support strings', function () {
var settings = cli.parse('node nodemon -v');
assert(settings.version === true, 'version flag');
});
it('should support short versions of flags', function () {
var settings = cli.parse('node nodemon -v -x java -I -V -q -w fixtures -i fixtures -d 5 -L -C -e pug -s SIGHUP');
assert(settings.version, 'version');
assert(settings.verbose, 'verbose');
assert(settings.exec === 'java', 'exec');
assert(settings.quiet, 'quiet');
assert(settings.stdin === false, 'read stdin');
assert(settings.watch[0] === 'fixtures', 'watch');
assert(settings.ignore[0] === 'fixtures', 'ignore');
assert(settings.delay === 5000, 'delay 5 seconds');
assert(settings.runOnChangeOnly, 'run on change only');
assert(settings.ext === 'pug', 'extension
gitextract_bisxif4y/
├── .eslintrc.json
├── .github/
│ ├── CONTRIBUTING.md
│ ├── FUNDING.yml
│ ├── ISSUE_TEMPLATE/
│ │ └── bug_report.md
│ ├── ISSUE_TEMPLATE.md
│ ├── no-response.yml
│ ├── oliver.yml
│ └── workflows/
│ ├── commits.yml
│ ├── node.js.yml
│ ├── release.yml
│ ├── stale.yml
│ └── website.yml
├── .gitignore
├── .jshintrc
├── .npmignore
├── .npmrc
├── .prettierrc.json
├── .releaserc
├── .travis.yml
├── CODE_OF_CONDUCT.md
├── Dockerfile
├── LICENSE
├── README.md
├── TODO.md
├── bin/
│ └── nodemon.js
├── commitlint.config.js
├── doc/
│ ├── arch.md
│ ├── cli/
│ │ ├── authors.txt
│ │ ├── config.txt
│ │ ├── help.txt
│ │ ├── logo.txt
│ │ ├── options.txt
│ │ ├── topics.txt
│ │ ├── usage.txt
│ │ └── whoami.txt
│ ├── events.md
│ ├── option-parsing-logic.md
│ ├── requireable.md
│ ├── rules.md
│ └── sample-nodemon.md
├── faq.md
├── index.d.ts
├── jsconfig.json
├── lib/
│ ├── cli/
│ │ ├── index.js
│ │ └── parse.js
│ ├── config/
│ │ ├── command.js
│ │ ├── defaults.js
│ │ ├── exec.js
│ │ ├── index.js
│ │ └── load.js
│ ├── help/
│ │ └── index.js
│ ├── index.js
│ ├── monitor/
│ │ ├── index.js
│ │ ├── match.js
│ │ ├── run.js
│ │ ├── signals.js
│ │ └── watch.js
│ ├── nodemon.js
│ ├── rules/
│ │ ├── add.js
│ │ ├── index.js
│ │ └── parse.js
│ ├── spawn.js
│ ├── utils/
│ │ ├── bus.js
│ │ ├── clone.js
│ │ ├── colour.js
│ │ ├── index.js
│ │ ├── log.js
│ │ └── merge.js
│ └── version.js
├── package.json
├── test/
│ ├── cli/
│ │ ├── exec.test.js
│ │ └── parse.test.js
│ ├── config/
│ │ ├── env.test.js
│ │ ├── load-logging.test.js
│ │ └── load.test.js
│ ├── docker.sh
│ ├── events/
│ │ ├── complete.test.js
│ │ └── scripts.test.js
│ ├── fixtures/
│ │ ├── .dotfile
│ │ ├── .dotfolder/
│ │ │ ├── .nested_dotfile.js
│ │ │ ├── second.js
│ │ │ └── some_file.js
│ │ ├── 1246/
│ │ │ ├── app/
│ │ │ │ └── index.js
│ │ │ └── watching/
│ │ │ └── index.js
│ │ ├── app with spaces.js
│ │ ├── app.coffee
│ │ ├── app.js
│ │ ├── comments
│ │ ├── configs/
│ │ │ ├── public-star.json
│ │ │ ├── top-level.json
│ │ │ ├── watch-options.json
│ │ │ ├── watch-relative-filter.json
│ │ │ └── watch-relative.json
│ │ ├── default
│ │ ├── default.json
│ │ ├── env.js
│ │ ├── events/
│ │ │ ├── env.js
│ │ │ └── nodemon.json
│ │ ├── global/
│ │ │ └── nodemon.json
│ │ ├── hello.ls
│ │ ├── hello.py
│ │ ├── help.txt
│ │ ├── legacy/
│ │ │ └── .nodemonignore
│ │ ├── log.coffee
│ │ ├── nodemon.json
│ │ ├── package.json
│ │ ├── packages/
│ │ │ ├── browserify/
│ │ │ │ └── package.json
│ │ │ ├── express4/
│ │ │ │ └── package.json
│ │ │ ├── main-and-index/
│ │ │ │ ├── index.js
│ │ │ │ ├── package.json
│ │ │ │ └── server.js
│ │ │ ├── main-and-start/
│ │ │ │ ├── index.js
│ │ │ │ └── package.json
│ │ │ ├── nodemon-settings-and-package-json-settings/
│ │ │ │ ├── nodemon.json
│ │ │ │ └── package.json
│ │ │ ├── package-json-settings/
│ │ │ │ └── package.json
│ │ │ ├── start/
│ │ │ │ └── package.json
│ │ │ ├── start-and-package-json-settings/
│ │ │ │ └── package.json
│ │ │ ├── start-and-settings/
│ │ │ │ ├── nodemon.json
│ │ │ │ └── package.json
│ │ │ └── start-ignored/
│ │ │ └── package.json
│ │ ├── regexp
│ │ ├── repl.js
│ │ ├── sigint.js
│ │ ├── simple
│ │ ├── simple.json
│ │ ├── super-legacy/
│ │ │ └── nodemon-ignore
│ │ └── watch-count/
│ │ ├── index.js
│ │ └── lib/
│ │ ├── 1.js
│ │ ├── 2.js
│ │ ├── 3.js
│ │ ├── 4.js
│ │ └── 5.js
│ ├── fork/
│ │ ├── change-detect.test.js
│ │ ├── config.test.js
│ │ ├── run-mac-only.test.js
│ │ ├── run.test.js
│ │ └── watch-restart.test.js
│ ├── help/
│ │ └── help.test.js
│ ├── lib/
│ │ ├── events.test.js
│ │ ├── require-restartable.test.js
│ │ └── require.test.js
│ ├── misc/
│ │ ├── listeners.test.js
│ │ └── sigint.test.js
│ ├── mocha.opts
│ ├── monitor/
│ │ ├── count.test.js
│ │ ├── ignore.test.js
│ │ ├── match.test.js
│ │ ├── run.test.js
│ │ ├── watch-restart.test.js
│ │ └── watch.test.js
│ ├── rules/
│ │ └── index.test.js
│ ├── utils/
│ │ ├── colour.test.js
│ │ ├── log.test.js
│ │ ├── merge.test.js
│ │ └── stringify.test.js
│ └── utils.js
└── website/
├── index.html
├── oc.jq
├── oc.js
└── style.css
SYMBOL INDEX (88 symbols across 34 files)
FILE: index.d.ts
type NodemonEventHandler (line 3) | type NodemonEventHandler =
type NodemonEventListener (line 15) | type NodemonEventListener = {
type NodemonEventLog (line 28) | type NodemonEventLog = {
type NodemonEventQuit (line 42) | type NodemonEventQuit = 143 | 130;
type NodemonEventConfig (line 44) | type NodemonEventConfig = {
type NodemonExecOptions (line 62) | interface NodemonExecOptions {
type NodemonConfig (line 72) | interface NodemonConfig {
type NodemonSettings (line 104) | interface NodemonSettings extends NodemonConfig, NodemonExecOptions {
type Nodemon (line 109) | type Nodemon = {
FILE: lib/cli/index.js
function stringToArgs (line 12) | function stringToArgs(string) {
FILE: lib/cli/parse.js
function parse (line 31) | function parse(argv) {
function nodemonOption (line 105) | function nodemonOption(options, arg, eatNext) {
function parseDelay (line 216) | function parseDelay(value) {
FILE: lib/config/command.js
function command (line 18) | function command(settings) {
FILE: lib/config/exec.js
function execFromPackage (line 15) | function execFromPackage() {
function replace (line 41) | function replace(map, str) {
function expandScript (line 48) | function expandScript(script, ext) {
function exec (line 77) | function exec(nodemonOptions, execMap) {
FILE: lib/config/index.js
function reset (line 16) | function reset() {
FILE: lib/config/load.js
function findAppScript (line 16) | function findAppScript() {
function load (line 38) | function load(settings, options, config, callback) {
function normaliseRules (line 118) | function normaliseRules(options, ready) {
function loadFile (line 137) | function loadFile(options, config, dir, ready) {
function loadPackageJSON (line 189) | function loadPackageJSON(config, ready) {
function mutateExecOptions (line 202) | function mutateExecOptions(options) {
FILE: lib/help/index.js
function help (line 9) | function help(item) {
FILE: lib/monitor/match.js
function rulesToMonitor (line 10) | function rulesToMonitor(watch, ignore, config) {
function tryBaseDir (line 109) | function tryBaseDir(dir) {
function match (line 136) | function match(files, monitor, ext) {
FILE: lib/monitor/run.js
function run (line 22) | function run(options) {
function waitForSubProcesses (line 322) | function waitForSubProcesses(pid, callback) {
function kill (line 338) | function kill(child, signal, callback) {
FILE: lib/monitor/watch.js
function resetWatchers (line 18) | function resetWatchers() {
function watch (line 26) | function watch() {
function filterAndRestart (line 137) | function filterAndRestart(files) {
function restartBus (line 223) | function restartBus(matched) {
function debounce (line 236) | function debounce(fn, delay) {
FILE: lib/nodemon.js
function nodemon (line 24) | function nodemon(settings) {
FILE: lib/rules/add.js
function add (line 33) | function add(rules, which, rule) {
FILE: lib/rules/index.js
function load (line 17) | function load(filename, callback) {
FILE: lib/rules/parse.js
function parse (line 11) | function parse(filename, callback) {
FILE: lib/utils/clone.js
function clone (line 4) | function clone(obj) {
FILE: lib/utils/colour.js
function colour (line 7) | function colour(c, str) {
function strip (line 11) | function strip(str) {
FILE: lib/utils/log.js
function log (line 15) | function log(type, text) {
FILE: lib/utils/merge.js
function typesMatch (line 5) | function typesMatch(a, b) {
function merge (line 15) | function merge(source, target, result) {
FILE: lib/version.js
function pin (line 9) | function pin() {
function version (line 15) | function version(callback) {
function findPackage (line 62) | function findPackage(dir) {
function command (line 77) | function command(cmd) {
function commit (line 89) | function commit() {
function branch (line 93) | function branch() {
function dirty (line 97) | function dirty() {
FILE: test/cli/exec.test.js
function toCmd (line 10) | function toCmd(options) {
FILE: test/cli/parse.test.js
function asCLI (line 12) | function asCLI(cmd) {
function parse (line 16) | function parse(cmd) {
function commandToString (line 34) | function commandToString(command) {
FILE: test/config/load.test.js
function asCLI (line 15) | function asCLI(cmd) {
function commandToString (line 19) | function commandToString(command) {
function removeRegExp (line 41) | function removeRegExp(options) {
FILE: test/events/complete.test.js
function conf (line 15) | function conf() {
FILE: test/events/scripts.test.js
function asCLI (line 13) | function asCLI(cmd) {
function parse (line 17) | function parse(cmd) {
function commandToString (line 23) | function commandToString(command) {
FILE: test/misc/listeners.test.js
function conf (line 11) | function conf() {
function run (line 33) | function run(n) {
FILE: test/misc/sigint.test.js
function runAndKill (line 12) | function runAndKill(done, cmdline, exitcb)
FILE: test/monitor/ignore.test.js
function ignore (line 15) | function ignore(rule, done, file) {
FILE: test/monitor/run.test.js
function rnd (line 10) | function rnd() {
FILE: test/monitor/watch-restart.test.js
function write (line 20) | function write(both) {
FILE: test/rules/index.test.js
function loadfixtures (line 8) | function loadfixtures(sample) {
FILE: test/utils.js
function asCLI (line 9) | function asCLI(cmd) {
function match (line 17) | function match(str, key) {
function monitorForChange (line 21) | function monitorForChange(str) {
function run (line 40) | function run(cmd, callbacks) {
function cleanup (line 81) | function cleanup(p, done, err) {
function Plan (line 98) | function Plan(count, done) {
function getTriggerCount (line 118) | function getTriggerCount(msg) {
function isRunning (line 124) | function isRunning(pid) {
FILE: test/utils/merge.test.js
function getOriginal (line 5) | function getOriginal() {
FILE: website/oc.js
function curl (line 22) | async function curl(out) {
function get (line 48) | function get(url) {
function getUpdates (line 80) | async function getUpdates(filename) {
function getContents (line 97) | async function getContents() {
function combine (line 109) | async function combine(insert, source, filename) {
function work (line 125) | async function work(tmp) {
function main (line 140) | async function main() {
Condensed preview — 161 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (349K chars).
[
{
"path": ".eslintrc.json",
"chars": 360,
"preview": "{\r\n \"env\": {\r\n \"browser\": true,\r\n \"commonjs\": true,\r\n \"es2021\": true\r\n },\r\n \"parserOptions"
},
{
"path": ".github/CONTRIBUTING.md",
"chars": 1455,
"preview": "# Contributing\n\n## Commit messages\n\nCommit messages must follow the [Angular-style](https://github.com/angular/angular.j"
},
{
"path": ".github/FUNDING.yml",
"chars": 40,
"preview": "github: [remy]\nopen_collective: nodemon\n"
},
{
"path": ".github/ISSUE_TEMPLATE/bug_report.md",
"chars": 898,
"preview": "---\nname: Bug report\nabout: Create a report to help nodemon improve\ntitle: ''\nlabels: ''\nassignees: ''\n\n---\n\n<!-- \n whe"
},
{
"path": ".github/ISSUE_TEMPLATE.md",
"chars": 646,
"preview": "<!-- \n when raising an issue please include replies to the following questions, \n and if you're reporting a bug, pleas"
},
{
"path": ".github/no-response.yml",
"chars": 723,
"preview": "# Configuration for probot-no-response - https://github.com/probot/no-response\n\n# Number of days of inactivity before an"
},
{
"path": ".github/oliver.yml",
"chars": 609,
"preview": "# Number of days the issue was closed in before the bot should reply.\n# If the issue was closed in more days than this, "
},
{
"path": ".github/workflows/commits.yml",
"chars": 296,
"preview": "name: Conventional Commit Checker\n\non:\n pull_request:\n branches: [main]\n types: [opened, edited, synchronize]\n\njo"
},
{
"path": ".github/workflows/node.js.yml",
"chars": 833,
"preview": "# This workflow will do a clean install of node dependencies, build the source code and run tests across different versi"
},
{
"path": ".github/workflows/release.yml",
"chars": 846,
"preview": "name: Release\non:\n workflow_run:\n workflows: [\"tests\"]\n branches: [main]\n types:\n - completed\n\njobs:\n re"
},
{
"path": ".github/workflows/stale.yml",
"chars": 1019,
"preview": "name: Mark stale issues and pull requests\n\non:\n schedule:\n - cron: \"0 * * * *\"\n\njobs:\n stale:\n\n runs-on: ubuntu-la"
},
{
"path": ".github/workflows/website.yml",
"chars": 1120,
"preview": "name: website\n\non:\n workflow_dispatch:\n\njobs:\n deploy:\n runs-on: ubuntu-latest\n permissions:\n contents: wri"
},
{
"path": ".gitignore",
"chars": 161,
"preview": "lib-cov\n*.seed\n*.log\n*.csv\n*.dat\n*.out\n*.pid\n*.gz\n\n.env\n\n.vscode/\n\npids\nlogs\nresults\n\nnpm-debug.log\nnode_modules\ncoverag"
},
{
"path": ".jshintrc",
"chars": 239,
"preview": "{\n \"browser\": true,\n \"camelcase\": true,\n \"curly\": true,\n \"devel\": true,\n \"eqeqeq\": true,\n \"forin\": true,\n \"indent"
},
{
"path": ".npmignore",
"chars": 132,
"preview": "test/\ntmp/\ncoverage/\nissues/\n.github/\nwebsite/\n*.md\nDockerfile\n.eslintrc.json\n.jshintrc\n.releaserc\n.travis.yml\ncommitlin"
},
{
"path": ".npmrc",
"chars": 18,
"preview": "package-lock=true\n"
},
{
"path": ".prettierrc.json",
"chars": 26,
"preview": "{\n \"singleQuote\": true\n}\n"
},
{
"path": ".releaserc",
"chars": 27,
"preview": "{\n \"branches\": [\"main\"]\n}\n"
},
{
"path": ".travis.yml",
"chars": 345,
"preview": "language: node_js\ncache:\n directories:\n - ~/.npm\nnotifications:\n email: false\nnode_js:\n - '14'\n - '12'\n - '10'\nb"
},
{
"path": "CODE_OF_CONDUCT.md",
"chars": 1980,
"preview": "# Contributor Code of Conduct\n\nAs contributors and maintainers of this project, and in the interest of fostering an open"
},
{
"path": "Dockerfile",
"chars": 917,
"preview": "#\n# Ubuntu Node.js Dockerfile\n#\n# https://github.com/dockerfile/ubuntu/blob/master/Dockerfile\n# https://docs.docker.com/"
},
{
"path": "LICENSE",
"chars": 1122,
"preview": "MIT License\n\nCopyright (c) 2010 - present, Remy Sharp, https://remysharp.com <remy@remysharp.com>\n\nPermission is hereby "
},
{
"path": "README.md",
"chars": 39874,
"preview": "<p align=\"center\">\n <a href=\"https://nodemon.io/\"><img src=\"https://user-images.githubusercontent.com/13700/35731649-65"
},
{
"path": "TODO.md",
"chars": 336,
"preview": "# TODO\n\nA rough outline of things I'd like to do with nodemon after 13 years of supporting the software:\n\n- Upgrade moch"
},
{
"path": "bin/nodemon.js",
"chars": 436,
"preview": "#!/usr/bin/env node\n\nconst cli = require('../lib/cli');\nconst nodemon = require('../lib/');\nconst options = cli.parse(pr"
},
{
"path": "commitlint.config.js",
"chars": 70,
"preview": "module.exports = {\n extends: ['@commitlint/config-conventional'],\n};\n"
},
{
"path": "doc/arch.md",
"chars": 661,
"preview": "# nodemon code arch\n\n```\nCLI -> parser -> nodemon options -> rules\n\nrules -> configure -> watch -> start process\n```\n\n##"
},
{
"path": "doc/cli/authors.txt",
"chars": 232,
"preview": "\n Remy Sharp - author and maintainer\n https://github.com/remy\n https://twitter.com/rem\n\n Contributors: https://git"
},
{
"path": "doc/cli/config.txt",
"chars": 1158,
"preview": "\n Typically the options to control nodemon are passed in via the CLI and are\n listed under: nodemon --help options\n\n "
},
{
"path": "doc/cli/help.txt",
"chars": 1268,
"preview": " Usage: nodemon [options] [script.js] [args]\n\n Options:\n\n --config file ............ alternate nodemon.json config fi"
},
{
"path": "doc/cli/logo.txt",
"chars": 799,
"preview": " ; ;\n kO. x0\n KMX, .:x0kc. 'KMN\n"
},
{
"path": "doc/cli/options.txt",
"chars": 1869,
"preview": "\nConfiguration\n --config <file> .......... alternate nodemon.json config file to use\n --exitcrash .............. exit "
},
{
"path": "doc/cli/topics.txt",
"chars": 325,
"preview": "\n options .................. show all available nodemon options\n config ................... default config options usi"
},
{
"path": "doc/cli/usage.txt",
"chars": 88,
"preview": " Usage: nodemon [nodemon options] [script.js] [args]\n\n See \"nodemon --help\" for more.\n"
},
{
"path": "doc/cli/whoami.txt",
"chars": 1223,
"preview": "__/\\\\\\\\\\_____/\\\\\\_______/\\\\\\\\\\_______/\\\\\\\\\\\\\\\\\\\\\\\\_____/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\__/\\\\\\\\____________/\\\\\\\\_______/\\\\\\\\\\_______/\\\\\\\\"
},
{
"path": "doc/events.md",
"chars": 2781,
"preview": "# Events\n\nnodemon will emit events based on the child process.\n\n## Commands\n\n- restart\n- config:update\n- quit\n\n## States"
},
{
"path": "doc/option-parsing-logic.md",
"chars": 166,
"preview": "# Option parsing logic\n\n1. Read all CLI arguments\n2. Load local config\n3. Load global config\n4. Try backup: package.main"
},
{
"path": "doc/requireable.md",
"chars": 1945,
"preview": "# Nodemon as a required module\n\nNodemon (as of 1.0.0) also works as a required module. At present, you can only require "
},
{
"path": "doc/rules.md",
"chars": 825,
"preview": "# Rules\n\nGiven a nodemon.json file that contains:\n\n```json\n{\n \"ignore\": [\"*.coffee\"],\n \"watch\": [\"server/*.coffee\", \"t"
},
{
"path": "doc/sample-nodemon.md",
"chars": 697,
"preview": "# Sample nodemon.json\n\nHere is an example (of a contrived) `nodemon.json` file:\n\n```json\n{\n \"restartable\": \"rs\",\n \"ign"
},
{
"path": "faq.md",
"chars": 15776,
"preview": "# FAQ\n\nThis is being added to as common issues occur on the [issues](http://github.com/remy/nodemon/issues), and where a"
},
{
"path": "index.d.ts",
"chars": 3396,
"preview": "import type { WatchOptions } from 'chokidar';\n\nexport type NodemonEventHandler =\n | 'start'\n | 'crash'\n | 'exit'\n | "
},
{
"path": "jsconfig.json",
"chars": 142,
"preview": "{\n \"compilerOptions\": {\n \"typeRoots\": [\"./index.d.ts\", \"./node_modules/@types\"],\n \"checkJs\": true\n },\n \"exclude"
},
{
"path": "lib/cli/index.js",
"chars": 1089,
"preview": "var parse = require('./parse');\n\n/**\n * Converts a string to command line args, in particular\n * groups together quoted "
},
{
"path": "lib/cli/parse.js",
"chars": 6105,
"preview": "/*\n\nnodemon is a utility for node, and replaces the use of the executable\nnode. So the user calls `nodemon foo.js` inste"
},
{
"path": "lib/config/command.js",
"chars": 1249,
"preview": "module.exports = command;\n\n/**\n * command constructs the executable command to run in a shell including the\n * user scri"
},
{
"path": "lib/config/defaults.js",
"chars": 979,
"preview": "var ignoreRoot = require('ignore-by-default').directories();\n\n// default options for config.options\nconst defaults = {\n "
},
{
"path": "lib/config/exec.js",
"chars": 7124,
"preview": "const path = require('path');\nconst fs = require('fs');\nconst existsSync = fs.existsSync;\nconst utils = require('../util"
},
{
"path": "lib/config/index.js",
"chars": 2511,
"preview": "/**\n * Manages the internal config of nodemon, checking for the state of support\n * with fs.watch, how nodemon can watch"
},
{
"path": "lib/config/load.js",
"chars": 6660,
"preview": "var debug = require('debug')('nodemon');\nvar fs = require('fs');\nvar path = require('path');\nvar exists = fs.exists || p"
},
{
"path": "lib/help/index.js",
"chars": 733,
"preview": "var fs = require('fs');\nvar path = require('path');\nconst supportsColor = require('supports-color');\n\nmodule.exports = h"
},
{
"path": "lib/index.js",
"chars": 38,
"preview": "module.exports = require('./nodemon');"
},
{
"path": "lib/monitor/index.js",
"chars": 82,
"preview": "module.exports = {\n run: require('./run'),\n watch: require('./watch').watch,\n};\n"
},
{
"path": "lib/monitor/match.js",
"chars": 7018,
"preview": "const { minimatch } = require('minimatch');\nconst path = require('path');\nconst fs = require('fs');\nconst debug = requir"
},
{
"path": "lib/monitor/run.js",
"chars": 16951,
"preview": "var debug = require('debug')('nodemon:run');\nconst statSync = require('fs').statSync;\nvar utils = require('../utils');\nv"
},
{
"path": "lib/monitor/signals.js",
"chars": 488,
"preview": "module.exports = {\n SIGHUP: 1,\n SIGINT: 2,\n SIGQUIT: 3,\n SIGILL: 4,\n SIGTRAP: 5,\n SIGABRT: 6,\n SIGBUS: 7,\n SIGFP"
},
{
"path": "lib/monitor/watch.js",
"chars": 6567,
"preview": "module.exports.watch = watch;\nmodule.exports.resetWatchers = resetWatchers;\n\nvar debug = require('debug')('nodemon:watch"
},
{
"path": "lib/nodemon.js",
"chars": 8978,
"preview": "var debug = require('debug')('nodemon');\nvar path = require('path');\nvar monitor = require('./monitor');\nvar cli = requi"
},
{
"path": "lib/rules/add.js",
"chars": 2667,
"preview": "'use strict';\n\nvar utils = require('../utils');\n\n// internal\nvar reEscComments = /\\\\#/g;\n// note that '^^' is used in pl"
},
{
"path": "lib/rules/index.js",
"chars": 1260,
"preview": "'use strict';\nvar utils = require('../utils');\nvar add = require('./add');\nvar parse = require('./parse');\n\n// exported\n"
},
{
"path": "lib/rules/parse.js",
"chars": 804,
"preview": "'use strict';\nvar fs = require('fs');\n\n/**\n * Parse the nodemon config file, supporting both old style\n * plain text con"
},
{
"path": "lib/spawn.js",
"chars": 1930,
"preview": "const path = require('path');\nconst utils = require('./utils');\nconst merge = utils.merge;\nconst bus = utils.bus;\nconst "
},
{
"path": "lib/utils/bus.js",
"chars": 946,
"preview": "var events = require('events');\nvar debug = require('debug')('nodemon');\nvar util = require('util');\n\nvar Bus = function"
},
{
"path": "lib/utils/clone.js",
"chars": 829,
"preview": "module.exports = clone;\n\n// via http://stackoverflow.com/a/728694/22617\nfunction clone(obj) {\n // Handle the 3 simple t"
},
{
"path": "lib/utils/colour.js",
"chars": 690,
"preview": "/**\n * Encodes a string in a colour: red, yellow or green\n * @param {String} c colour to highlight in\n * @param {Str"
},
{
"path": "lib/utils/index.js",
"chars": 2624,
"preview": "var noop = function () { };\nvar path = require('path');\nconst semver = require('semver');\nvar version = process.versions"
},
{
"path": "lib/utils/log.js",
"chars": 1738,
"preview": "var colour = require('./colour');\nvar bus = require('./bus');\nvar required = false;\nvar useColours = true;\n\nvar coding ="
},
{
"path": "lib/utils/merge.js",
"chars": 1186,
"preview": "var clone = require('./clone');\n\nmodule.exports = merge;\n\nfunction typesMatch(a, b) {\n return (typeof a === typeof b) &"
},
{
"path": "lib/version.js",
"chars": 2465,
"preview": "module.exports = version;\nmodule.exports.pin = pin;\n\nvar fs = require('fs');\nvar path = require('path');\nvar exec = requ"
},
{
"path": "package.json",
"chars": 2133,
"preview": "{\n \"name\": \"nodemon\",\n \"homepage\": \"https://nodemon.io\",\n \"author\": {\n \"name\": \"Remy Sharp\",\n \"url\": \"https://g"
},
{
"path": "test/cli/exec.test.js",
"chars": 7808,
"preview": "'use strict';\n/*global describe:true, it: true */\nconst path = require('path');\nconst exec = require('../../lib/config/e"
},
{
"path": "test/cli/parse.test.js",
"chars": 16369,
"preview": "'use strict';\n/*global describe:true, it: true */\nvar cli = require('../../lib/cli/'),\n exec = require('../../lib/confi"
},
{
"path": "test/config/env.test.js",
"chars": 915,
"preview": "'use strict';\n/*global describe:true, it: true, after: true */\nvar nodemon = require('../../lib/'),\n path = require('pa"
},
{
"path": "test/config/load-logging.test.js",
"chars": 2298,
"preview": "'use strict';\n/*global describe, it, afterEach, beforeEach, after */\nconst load = require('../../lib/config/load');\ncons"
},
{
"path": "test/config/load.test.js",
"chars": 10912,
"preview": "'use strict';\n/*global describe, it, afterEach, beforeEach, after */\nvar load = require('../../lib/config/load');\nvar de"
},
{
"path": "test/docker.sh",
"chars": 219,
"preview": "docker build -t nodemon-test-env .\ndocker run --mount type=bind,source=/Users/remy/Sites/nodemon,target=/src/nodemon --n"
},
{
"path": "test/events/complete.test.js",
"chars": 2968,
"preview": "'use strict';\n/* global describe, it, beforeEach, before, after */\nvar nodemon = require('../../lib/');\nvar debug = requ"
},
{
"path": "test/events/scripts.test.js",
"chars": 2084,
"preview": "'use strict';\n/*global describe:true, it: true, afterEach: true, beforeEach: true, after:true */\nvar cli = require('../."
},
{
"path": "test/fixtures/.dotfile",
"chars": 0,
"preview": ""
},
{
"path": "test/fixtures/.dotfolder/.nested_dotfile.js",
"chars": 0,
"preview": ""
},
{
"path": "test/fixtures/.dotfolder/second.js",
"chars": 0,
"preview": ""
},
{
"path": "test/fixtures/.dotfolder/some_file.js",
"chars": 0,
"preview": ""
},
{
"path": "test/fixtures/1246/app/index.js",
"chars": 73,
"preview": "require('http').createServer((req, res) => res.end('ok')).listen(8000);\n\n"
},
{
"path": "test/fixtures/1246/watching/index.js",
"chars": 73,
"preview": "require('http').createServer((req, res) => res.end('ok')).listen(8000);\n\n"
},
{
"path": "test/fixtures/app with spaces.js",
"chars": 187,
"preview": "#!/usr/bin/env node\nconsole.log(process.argv[2] || 'OK');\nrequire('http').createServer(function (req, res) { console.log"
},
{
"path": "test/fixtures/app.coffee",
"chars": 156,
"preview": "http = require 'http'\nserver = http.createServer (req, res) -> res.end 'hi\\n'\nserver.listen process.env.PORT || 8000\n# c"
},
{
"path": "test/fixtures/app.js",
"chars": 291,
"preview": "// process.title = 'node (fixtures/app)';\n// console.log('starting up @ ' + (process.env.PORT || 8000));\nrequire('http')"
},
{
"path": "test/fixtures/comments",
"chars": 54,
"preview": "# this is a comment\n\n# this is another comment\n\n# *.js"
},
{
"path": "test/fixtures/configs/public-star.json",
"chars": 71,
"preview": "{\n \"ignore\": \"public/*\",\n \"ext\": \"json,js,html\",\n \"verbose\": true\n}\n"
},
{
"path": "test/fixtures/configs/top-level.json",
"chars": 186,
"preview": "{\n \"verbose\": \"true\",\n \"watch\": [\n \"*.js\",\n \"app/\",\n \"helpers/\",\n \"routes/\",\n \"view/\",\n \"views/\"\n ]"
},
{
"path": "test/fixtures/configs/watch-options.json",
"chars": 82,
"preview": "{\n \"ext\": \"json,js,html\",\n \"watchOptions\": {\n \"awaitWriteFinish\": true\n }\n}\n"
},
{
"path": "test/fixtures/configs/watch-relative-filter.json",
"chars": 112,
"preview": "{\n \"ext\": \"json,js,html\",\n \"watch\": [\"../jsbin/views\", \"../jsbin/lib\", \"../jsbin/*.json\", \"config.dev.json\"]\n}"
},
{
"path": "test/fixtures/configs/watch-relative.json",
"chars": 54,
"preview": "{\n \"watch\": [\n \"../../../lib\"\n ],\n \"ext\": \"py\"\n}"
},
{
"path": "test/fixtures/default",
"chars": 277,
"preview": "# this is my ignore file with a nice comment at the top\n\n/vendor/* # ignore all external submodules\n/public/* # "
},
{
"path": "test/fixtures/default.json",
"chars": 243,
"preview": "{\n \"watch\": [\n \"./\",\n \"lib\",\n \"src\",\n \"plugins\"\n ],\n \"ext\": \"js css html\",\n \"exec\": \"node\",\n \"delay\": 2"
},
{
"path": "test/fixtures/env.js",
"chars": 38,
"preview": "console.log(process.env.NODEMON_ENV);\n"
},
{
"path": "test/fixtures/events/env.js",
"chars": 30,
"preview": "console.log(process.env.USER);"
},
{
"path": "test/fixtures/events/nodemon.json",
"chars": 171,
"preview": "{\n \"verbose\": \"true\",\n \"ext\": \"js\",\n \"events\": {\n \"start\": \"echo 'OK'\",\n \"crash\": \"echo 'CRASHED'\",\n \"exit\":"
},
{
"path": "test/fixtures/global/nodemon.json",
"chars": 115,
"preview": "{\n \"verbose\": true,\n \"ignore\": [\"one\", \"two\"],\n \"execMap\": {\n \"pug\": \"bin/pug {{filename}} --out /tmp\"\n }\n}\n"
},
{
"path": "test/fixtures/hello.ls",
"chars": 136,
"preview": "http = require 'http'\nserver = http.createServer (req, res) -> res.end 'hi\\n'\nserver.listen process.env.PORT\nconsole.log"
},
{
"path": "test/fixtures/hello.py",
"chars": 22,
"preview": "print(\"Hello, World!\")"
},
{
"path": "test/fixtures/help.txt",
"chars": 29,
"preview": "This file should not be read."
},
{
"path": "test/fixtures/legacy/.nodemonignore",
"chars": 310,
"preview": "# this is my ignore file with a nice comment at the top\n\n/vendor/* # ignore all external submodules\n/public/* # "
},
{
"path": "test/fixtures/log.coffee",
"chars": 27,
"preview": "console.log \"CoffeeScript!\""
},
{
"path": "test/fixtures/nodemon.json",
"chars": 141,
"preview": "{\n \"ignore\": [\"one\", \"three\"],\n \"watch\": [\"four\"],\n \"env\": {\n \"USER\": \"remysharp\"\n },\n \"execMap\": {\n \"js\": \"n"
},
{
"path": "test/fixtures/package.json",
"chars": 22,
"preview": "{\n \"main\": \"app.js\"\n}"
},
{
"path": "test/fixtures/packages/browserify/package.json",
"chars": 78,
"preview": "{\n \"scripts\": {\n \"start\": \"browserify -t hbsfy app.js -o bundle.js\"\n }\n}\n"
},
{
"path": "test/fixtures/packages/express4/package.json",
"chars": 375,
"preview": "{\n \"name\": \"express4-gen\",\n \"version\": \"0.0.1\",\n \"private\": true,\n \"scripts\": {\n \"start\": \"NODE_ENV=development n"
},
{
"path": "test/fixtures/packages/main-and-index/index.js",
"chars": 0,
"preview": ""
},
{
"path": "test/fixtures/packages/main-and-index/package.json",
"chars": 26,
"preview": "{\n \"main\": \"server.js\"\n}\n"
},
{
"path": "test/fixtures/packages/main-and-index/server.js",
"chars": 0,
"preview": ""
},
{
"path": "test/fixtures/packages/main-and-start/index.js",
"chars": 0,
"preview": ""
},
{
"path": "test/fixtures/packages/main-and-start/package.json",
"chars": 76,
"preview": "{\n \"main\": \"./index.js\",\n \"scripts\": {\n \"start\": \"node index.js\"\n }\n}\n"
},
{
"path": "test/fixtures/packages/nodemon-settings-and-package-json-settings/nodemon.json",
"chars": 20,
"preview": "{\n \"exec\": \"foo\"\n}\n"
},
{
"path": "test/fixtures/packages/nodemon-settings-and-package-json-settings/package.json",
"chars": 55,
"preview": "{\n \"nodemonConfig\": {\n \"exec\": \"foo-ignored\"\n }\n}\n"
},
{
"path": "test/fixtures/packages/package-json-settings/package.json",
"chars": 102,
"preview": "{\n \"nodemonConfig\": {\n \"exec\": \"foo\",\n \"ignore\": [\"one\", \"three\"],\n \"watch\": [\"four\"]\n }\n}\n"
},
{
"path": "test/fixtures/packages/start/package.json",
"chars": 49,
"preview": "{\n \"scripts\": {\n \"start\": \"node app.js\"\n }\n}"
},
{
"path": "test/fixtures/packages/start-and-package-json-settings/package.json",
"chars": 94,
"preview": "{\n \"scripts\": {\n \"start\": \"node app.js\"\n },\n \"nodemonConfig\": {\n \"exec\": \"foo\"\n }\n}\n"
},
{
"path": "test/fixtures/packages/start-and-settings/nodemon.json",
"chars": 20,
"preview": "{\n \"exec\": \"foo\"\n}\n"
},
{
"path": "test/fixtures/packages/start-and-settings/package.json",
"chars": 50,
"preview": "{\n \"scripts\": {\n \"start\": \"node app.js\"\n }\n}\n"
},
{
"path": "test/fixtures/packages/start-ignored/package.json",
"chars": 34,
"preview": "{ \"scripts\": { \"start\": \"foo\" } }\n"
},
{
"path": "test/fixtures/regexp",
"chars": 71,
"preview": ":(\\d)*\\.js # monitor javascript files with only digits in their name"
},
{
"path": "test/fixtures/repl.js",
"chars": 245,
"preview": "var repl = require('repl');\n\n// Start Express or something, when it's up, startup the REPL\nvar rpl = repl.start('REPL> '"
},
{
"path": "test/fixtures/sigint.js",
"chars": 232,
"preview": "process.on('SIGINT', function() {\n if (process.argv.length === 3 && process.argv[2] === '--dont-exit') return;\n proces"
},
{
"path": "test/fixtures/simple",
"chars": 200,
"preview": "# this is my ignore file with a nice comment at the top\n\n/vendor/* # ignore all external submodules\n/public/* # "
},
{
"path": "test/fixtures/simple.json",
"chars": 66,
"preview": "{\n \"watch\": [\n \"*.js\"\n ],\n \"ignore\": [\n \"/public/*\"\n ]\n}"
},
{
"path": "test/fixtures/super-legacy/nodemon-ignore",
"chars": 277,
"preview": "# this is my ignore file with a nice comment at the top\n\n/vendor/* # ignore all external submodules\n/public/* # "
},
{
"path": "test/fixtures/watch-count/index.js",
"chars": 5,
"preview": "true;"
},
{
"path": "test/fixtures/watch-count/lib/1.js",
"chars": 0,
"preview": ""
},
{
"path": "test/fixtures/watch-count/lib/2.js",
"chars": 0,
"preview": ""
},
{
"path": "test/fixtures/watch-count/lib/3.js",
"chars": 0,
"preview": ""
},
{
"path": "test/fixtures/watch-count/lib/4.js",
"chars": 0,
"preview": ""
},
{
"path": "test/fixtures/watch-count/lib/5.js",
"chars": 0,
"preview": ""
},
{
"path": "test/fork/change-detect.test.js",
"chars": 2955,
"preview": "'use strict';\n/*global describe:true, it: true */\nvar utils = require('../utils'),\n colour = require('../../lib/utils/c"
},
{
"path": "test/fork/config.test.js",
"chars": 1212,
"preview": "'use strict';\n/*global describe:true, it: true, afterEach:true, beforeEach:true */\nvar assert = require('assert'),\n u"
},
{
"path": "test/fork/run-mac-only.test.js",
"chars": 2289,
"preview": "const fs = require('fs');\nconst assert = require('assert');\nconst utils = require('../utils');\nconst appJS = utils.appjs"
},
{
"path": "test/fork/run.test.js",
"chars": 3943,
"preview": "/*global describe:true, it: true */\nvar assert = require('assert'),\n utils = require('../utils'),\n appjs = utils.appjs"
},
{
"path": "test/fork/watch-restart.test.js",
"chars": 5429,
"preview": "'use strict';\n/*global describe:true, it: true, after: true */\nvar assert = require('assert'),\n fs = require('fs'),\n "
},
{
"path": "test/help/help.test.js",
"chars": 654,
"preview": "/*global describe:true, it: true */\nvar help = require('../../lib/help'),\n assert = require('assert');\n\ndescribe('hel"
},
{
"path": "test/lib/events.test.js",
"chars": 397,
"preview": "/*global describe:true, it: true */\nvar nodemon = require('../../lib/'),\n assert = require('assert');\n\ndescribe('node"
},
{
"path": "test/lib/require-restartable.test.js",
"chars": 1443,
"preview": "'use strict';\n/*global describe:true, it: true, afterEach: true */\nvar nodemon = require('../../lib/'),\n assert = req"
},
{
"path": "test/lib/require.test.js",
"chars": 2712,
"preview": "'use strict';\n/*global describe:true, it: true, afterEach: true */\nvar nodemon = require('../../lib/'),\n assert = requi"
},
{
"path": "test/misc/listeners.test.js",
"chars": 1137,
"preview": "/*global describe, it, beforeEach */\n\nvar nodemon = require('../../lib/');\nvar assert = require('assert');\nvar path = re"
},
{
"path": "test/misc/sigint.test.js",
"chars": 1457,
"preview": "'use strict';\n/*global describe:true, it: true */\nvar utils = require('../utils'),\n assert = require('assert'),\n p"
},
{
"path": "test/mocha.opts",
"chars": 25,
"preview": "--reporter spec\n--ui bdd\n"
},
{
"path": "test/monitor/count.test.js",
"chars": 2425,
"preview": "'use strict';\n/*global describe:true, it: true, after: true */\nvar nodemon = require('../../lib/');\nvar utils = require("
},
{
"path": "test/monitor/ignore.test.js",
"chars": 1825,
"preview": "'use strict';\n/*global describe:true, it: true, after: true */\nvar assert = require('assert'),\n path = require('path'),"
},
{
"path": "test/monitor/match.test.js",
"chars": 15570,
"preview": "'use strict';\n/*global describe:true, it: true */\nvar assert = require('assert'),\n match = require('../../lib/monitor/m"
},
{
"path": "test/monitor/run.test.js",
"chars": 5600,
"preview": "'use strict';\n/*global describe:true, it: true, after: true, beforeEach */\nvar nodemon = require('../../lib/');\nvar asse"
},
{
"path": "test/monitor/watch-restart.test.js",
"chars": 5031,
"preview": "'use strict';\n/*global describe, it, after, afterEach */\nlet debugLogger = {};\nconst nodemon = require('../../lib/');\nva"
},
{
"path": "test/monitor/watch.test.js",
"chars": 840,
"preview": "'use-strict';\n\nvar assert = require('assert');\nvar chokidar = require('chokidar');\nvar process = require('process');\nvar"
},
{
"path": "test/rules/index.test.js",
"chars": 1992,
"preview": "'use strict';\n/*global describe:true, it: true, beforeEach: true */\nvar fs = require('fs'),\n nodemon = require('../.."
},
{
"path": "test/utils/colour.test.js",
"chars": 457,
"preview": "/*global describe:true, it: true */\nvar colour = require('../../lib/utils/colour'),\n assert = require('assert');\n\ndes"
},
{
"path": "test/utils/log.test.js",
"chars": 1890,
"preview": "'use strict';\n/*global describe:true, it: true */\nvar Logger = require('../../lib/utils/log');\nvar logger = new Logger(t"
},
{
"path": "test/utils/merge.test.js",
"chars": 3321,
"preview": "/*global describe:true, it: true */\nvar merge = require('../../lib/utils/merge'),\n assert = require('assert');\n\nfunct"
},
{
"path": "test/utils/stringify.test.js",
"chars": 1094,
"preview": "'use strict';\n/*global describe:true, it: true */\nvar stringify = require('../../lib/utils').stringify,\n assert = req"
},
{
"path": "test/utils.js",
"chars": 3202,
"preview": "'use strict';\nvar fork = require('child_process').fork,\n path = require('path'),\n appjs = path.resolve(__dirname, "
},
{
"path": "website/index.html",
"chars": 28366,
"preview": "<!DOCTYPE html>\n<html>\n\n <head>\n <meta charset=utf-8>\n <meta name=\"viewport\" content=\"width=device-width\">\n <t"
},
{
"path": "website/oc.jq",
"chars": 4588,
"preview": "def getImage:\n\t. as $_ |\n\t{\n \"206432\": \"https://user-images.githubusercontent.com/13700/127474039-8ba5ac8c-2095-498"
},
{
"path": "website/oc.js",
"chars": 4375,
"preview": "const util = require('node:util');\nconst exec = util.promisify(require('node:child_process').exec);\nconst { readFile, wr"
},
{
"path": "website/style.css",
"chars": 2057,
"preview": "body,\nhtml {\n margin: 0;\n min-height: 100%;\n background: #2b2922;\n color: #eee;\n font-family: -apple-system, BlinkM"
}
]
About this extraction
This page contains the full source code of the remy/nodemon GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 161 files (320.9 KB), approximately 90.8k tokens, and a symbol index with 88 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.