<NME> README.md
<BEF> # ts-node-dev

> Tweaked version of [node-dev](https://github.com/fgnass/node-dev) that uses [ts-node](https://github.com/TypeStrong/ts-node) under the hood.

It restarts target node process when any of required files changes (as standard `node-dev`) but shares [Typescript](https://github.com/Microsoft/TypeScript/) compilation process between restarts. This significantly increases speed of restarting comparing to `node-dev -r ts-node/register ...`, `nodemon -x ts-node ...` variations because there is no need to instantiate `ts-node` compilation each time.

## Install

![npm (scoped)](https://img.shields.io/npm/v/ts-node-dev.svg?maxAge=86400) [![Build Status](https://travis-ci.com/wclr/ts-node-dev.svg?branch=master)](https://travis-ci.com/wclr/ts-node-dev)

```
yarn add ts-node-dev --dev
```

```
npm i ts-node-dev --save-dev
```

## Usage

```
ts-node-dev [node-dev|ts-node flags] [ts-node-dev flags] [node cli flags] [--] [script] [script arguments]
```

So you just combine [node-dev](https://github.com/fgnass/node-dev) and [ts-node](https://github.com/TypeStrong/ts-node) options (see docs of those packages):

```
ts-node-dev --respawn --transpile-only server.ts
```

There is also short alias `tsnd` for running `ts-node-dev`:
node-dev foo.js
```

There are two command line options that can be used to control how many files
are watched:

* `--no-deps` Watch only the project's own files and linked modules (via `npm link`)
* `--all-deps` Watch the whole dependency tree

By default node-dev will watch all first-level dependencies, i.e. the ones in
the project's `node_modules`folder.
* `--interval` - Polling interval (ms) - DOESN'T WORK CURRENTLY
* `--debounce` - Debounce file change events (ms, non-polling mode)
* `--clear` (`--cls`) - Will clear screen on restart
* `--watch` - Explicitly add arbitrary files or folders to watch and restart on change (list separated by commas, [chokidar](https://github.com/paulmillr/chokidar) patterns)
* `--exit-child` - Adds 'SIGTERM' exit handler in a child process.
* `--rs` - Allow to restart with "rs" line entered in stdio, disabled by default.
* `--notify` - to display desktop-notifications (Notifications are only displayed if `node-notifier` is installed).
* `--cache-directory` - tmp dir which is used to keep the compiled sources (by default os tmp directory is used)

If you need to detect that you are running with `ts-node-dev`, check if `process.env.TS_NODE_DEV` is set.


**Points of notice:**

- If you want desktop-notifications you should install `node-notifier` package and use `--notify` flag.

- Especially for large code bases always consider running with `--transpile-only` flag which is normal for dev workflow and will speed up things greatly. Note, that `ts-node-dev` will not put watch handlers on TS files that contain only types/interfaces (used only for type checking) - this is current limitation by design.

- `--ignore-watch` will NOT affect files ignored by TS compilation. Use `--ignore` option (or `TS_NODE_IGNORE` env variable) to pass **RegExp strings** for filtering files that should not be compiled, by default `/node_modules/` are ignored.

- Unknown flags (`node` cli flags are considered to be so) are treated like string value flags by default. The right solution to avoid ambiguity is to separate script name from option flags with `--`, for example:

  ```
  ts-node-dev --inspect -- my-script.ts
  ```

- The good thing is that `ts-node-dev` watches used `tsconfig.json` file, and will reinitialize compilation on its change, but you have to restart the process manually when you update used version of `typescript` or make any other changes that may effect compilation results.

## Issues

If you have an issue, please create one. But, before:
- try to check if there exits alike issues.
- try to run your code with just [ts-node](https://github.com/TypeStrong/ts-node)
- try to run your code with `--files` option enabled ([see ts-node docs](https://github.com/TypeStrong/ts-node#help-my-types-are-missing))
- try to run it with `--debug` flag and see the output
- try to make create repro example

## Versioning

Currently versioning is not stable and it is still treated as pre-release. You might expect some options API changes. If you want to avoid unexpected problems it is recommended to fixate the installed version and update only in case of issues, you may consult [CHANGELOG](CHANGELOG.md) for updates.

## License

MIT.

<MSG> Merge pull request #120 from tomekwi/notify-cli

Add a `--no-notify` CLI flag
<DFF> @@ -32,11 +32,15 @@ Just run `node-dev` as you would normally run `node`:
 node-dev foo.js
 ```
 
-There are two command line options that can be used to control how many files
-are watched:
+There are a couple of command line options that can be used to control which
+files are watched and what happens when they change:
 
 * `--no-deps` Watch only the project's own files and linked modules (via `npm link`)
 * `--all-deps` Watch the whole dependency tree
+* `--respawn` Keep watching for changes after the script has exited
+* `--dedupe` [Dedupe dynamically](https://www.npmjs.org/package/dynamic-dedupe)
+* `--poll` Force polling for file changes (Caution! CPU-heavy!)
+* `--no-notify` Switch off desktop notifications (see below)
 
 By default node-dev will watch all first-level dependencies, i.e. the ones in
 the project's `node_modules`folder.

{'commit': "diff --git a/README.md b/README.md\nindex ba14d21..af06bb0 100644\n--- a/README.md\n+++ b/README.md\n@@ -32,11 +32,15 @@ Just run `node-dev` as you would normally run `node`:\n node-dev foo.js\n ```\n \n-There are two command line options that can be used to control how many files\n-are watched:\n+There are a couple of command line options that can be used to control which\n+files are watched and what happens when they change:\n \n * `--no-deps` Watch only the project's own files and linked modules (via `npm link`)\n * `--all-deps` Watch the whole dependency tree\n+* `--respawn` Keep watching for changes after the script has exited\n+* `--dedupe` [Dedupe dynamically](https://www.npmjs.org/package/dynamic-dedupe)\n+* `--poll` Force polling for file changes (Caution! CPU-heavy!)\n+* `--no-notify` Switch off desktop notifications (see below)\n \n By default node-dev will watch all first-level dependencies, i.e. the ones in\n the project's `node_modules`folder.\ndiff --git a/bin/node-dev b/bin/node-dev\nindex f51f4c9..538a881 100755\n--- a/bin/node-dev\n+++ b/bin/node-dev\n@@ -31,7 +31,7 @@ var scriptArgs = process.argv.slice(scriptIndex + 1);\n var devArgs = process.argv.slice(2, scriptIndex);\n \n var opts = minimist(devArgs, {\n-  boolean: ['all-deps', 'deps', 'dedupe', 'poll', 'respawn'],\n+  boolean: ['all-deps', 'deps', 'dedupe', 'poll', 'respawn', 'notify'],\n   default: { deps: true },\n   unknown: function (arg) {\n     nodeArgs.push(arg);\ndiff --git a/lib/cfg.js b/lib/cfg.js\nindex 70f0f85..791542c 100644\n--- a/lib/cfg.js\n+++ b/lib/cfg.js\n@@ -27,6 +27,7 @@ module.exports = function (main, opts) {\n     if (!opts.deps) c.deps = 0;\n     if (opts.dedupe) c.dedupe = true;\n     if (opts.respawn) c.respawn = true;\n+    if (opts.notify === false) c.notify = false;\n   }\n \n   var ignore = (c.ignore || []).map(resolvePath);\n", 'commit_subject': 'Merge pull request #120 from tomekwi/notify-cli', 'repo_name': 'whitecolor/ts-node-dev', 'committer': {'name': 'Felix Gnass', 'email': '02fab21d2072ccd9eefccc8eac4a8d117b211092@gmail.com', 'time_sec': '1455320235', 'tz_offset': '60', 'date': {'seconds': '1455320235'}}, 'commit_tree': 'aa63ae643600af35c1d13ee394d6bc3614f67e03', 'commit_message': 'Merge pull request #120 from tomekwi/notify-cli\n\nAdd a `--no-notify` CLI flag', 'language_name': 'TypeScript', 'license': 'mit', 'hunks': "@@ -32,11 +32,15 @@ Just run `node-dev` as you would normally run `node`:\n node-dev foo.js\n ```\n \n-There are two command line options that can be used to control how many files\n-are watched:\n+There are a couple of command line options that can be used to control which\n+files are watched and what happens when they change:\n \n * `--no-deps` Watch only the project's own files and linked modules (via `npm link`)\n * `--all-deps` Watch the whole dependency tree\n+* `--respawn` Keep watching for changes after the script has exited\n+* `--dedupe` [Dedupe dynamically](https://www.npmjs.org/package/dynamic-dedupe)\n+* `--poll` Force polling for file changes (Caution! CPU-heavy!)\n+* `--no-notify` Switch off desktop notifications (see below)\n \n By default node-dev will watch all first-level dependencies, i.e. the ones in\n the project's `node_modules`folder.\n", 'addition_count': 6, 'deletion_count': 2, 'src_file': 'a/README.md', 'tgt_file': 'b/README.md', 'file_extension': '.md', 'before_file': '# ts-node-dev\n\n> Tweaked version of [node-dev](https://github.com/fgnass/node-dev) that uses [ts-node](https://github.com/TypeStrong/ts-node) under the hood.\n\nIt restarts target node process when any of required files changes (as standard `node-dev`) but shares [Typescript](https://github.com/Microsoft/TypeScript/) compilation process between restarts. This significantly increases speed of restarting comparing to `node-dev -r ts-node/register ...`, `nodemon -x ts-node ...` variations because there is no need to instantiate `ts-node` compilation each time.\n\n## Install\n\n![npm (scoped)](https://img.shields.io/npm/v/ts-node-dev.svg?maxAge=86400) [![Build Status](https://travis-ci.com/wclr/ts-node-dev.svg?branch=master)](https://travis-ci.com/wclr/ts-node-dev)\n\n```\nyarn add ts-node-dev --dev\n```\n\n```\nnpm i ts-node-dev --save-dev\n```\n\n## Usage\n\n```\nts-node-dev [node-dev|ts-node flags] [ts-node-dev flags] [node cli flags] [--] [script] [script arguments]\n```\n\nSo you just combine [node-dev](https://github.com/fgnass/node-dev) and [ts-node](https://github.com/TypeStrong/ts-node) options (see docs of those packages):\n\n```\nts-node-dev --respawn --transpile-only server.ts\n```\n\nThere is also short alias `tsnd` for running `ts-node-dev`:\nnode-dev foo.js\n```\n\nThere are two command line options that can be used to control how many files\nare watched:\n\n* `--no-deps` Watch only the project\'s own files and linked modules (via `npm link`)\n* `--all-deps` Watch the whole dependency tree\n\nBy default node-dev will watch all first-level dependencies, i.e. the ones in\nthe project\'s `node_modules`folder.\n* `--interval` - Polling interval (ms) - DOESN\'T WORK CURRENTLY\n* `--debounce` - Debounce file change events (ms, non-polling mode)\n* `--clear` (`--cls`) - Will clear screen on restart\n* `--watch` - Explicitly add arbitrary files or folders to watch and restart on change (list separated by commas, [chokidar](https://github.com/paulmillr/chokidar) patterns)\n* `--exit-child` - Adds \'SIGTERM\' exit handler in a child process.\n* `--rs` - Allow to restart with "rs" line entered in stdio, disabled by default.\n* `--notify` - to display desktop-notifications (Notifications are only displayed if `node-notifier` is installed).\n* `--cache-directory` - tmp dir which is used to keep the compiled sources (by default os tmp directory is used)\n\nIf you need to detect that you are running with `ts-node-dev`, check if `process.env.TS_NODE_DEV` is set.\n\n\n**Points of notice:**\n\n- If you want desktop-notifications you should install `node-notifier` package and use `--notify` flag.\n\n- Especially for large code bases always consider running with `--transpile-only` flag which is normal for dev workflow and will speed up things greatly. Note, that `ts-node-dev` will not put watch handlers on TS files that contain only types/interfaces (used only for type checking) - this is current limitation by design.\n\n- `--ignore-watch` will NOT affect files ignored by TS compilation. Use `--ignore` option (or `TS_NODE_IGNORE` env variable) to pass **RegExp strings** for filtering files that should not be compiled, by default `/node_modules/` are ignored.\n\n- Unknown flags (`node` cli flags are considered to be so) are treated like string value flags by default. The right solution to avoid ambiguity is to separate script name from option flags with `--`, for example:\n\n  ```\n  ts-node-dev --inspect -- my-script.ts\n  ```\n\n- The good thing is that `ts-node-dev` watches used `tsconfig.json` file, and will reinitialize compilation on its change, but you have to restart the process manually when you update used version of `typescript` or make any other changes that may effect compilation results.\n\n## Issues\n\nIf you have an issue, please create one. But, before:\n- try to check if there exits alike issues.\n- try to run your code with just [ts-node](https://github.com/TypeStrong/ts-node)\n- try to run your code with `--files` option enabled ([see ts-node docs](https://github.com/TypeStrong/ts-node#help-my-types-are-missing))\n- try to run it with `--debug` flag and see the output\n- try to make create repro example\n\n## Versioning\n\nCurrently versioning is not stable and it is still treated as pre-release. You might expect some options API changes. If you want to avoid unexpected problems it is recommended to fixate the installed version and update only in case of issues, you may consult [CHANGELOG](CHANGELOG.md) for updates.\n\n## License\n\nMIT.\n', 'message': 'Merge pull request #120 from tomekwi/notify-cli\n\nAdd a `--no-notify` CLI flag', 'author_name': 'Felix Gnass', 'lang': 'md'}