# child-process-debug

> Convenience methods for debugging child-process

Latest version **0.0.7** (published 2015-03-07) · MIT license · 695 weekly downloads

## Install

```sh
npm install child-process-debug
pnpm add child-process-debug
yarn add child-process-debug
bun add child-process-debug
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2015-03-07 |
| First published | 2015-02-12 |
| Weekly downloads | 695 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.33 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | James Hartig |
| Maintainers | fastest963 |
| Keywords | child_process, child, process, debug, debugger |

## Links

- npm: https://www.npmjs.com/package/child-process-debug
- Repository: https://github.com/fastest963/child-process-debug
- Issues: https://github.com/fastest963/child-process-debug/issues
- npm.io page: https://npm.io/package/child-process-debug

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [ton-logger](https://npm.io/package/ton-logger.md) — 457 weekly downloads

## Recent versions

- 0.0.7 (latest) — 2015-03-07
- 0.0.6 — 2015-02-28
- 0.0.5 — 2015-02-26
- 0.0.4 — 2015-02-13
- 0.0.3 — 2015-02-12
- 0.0.2 — 2015-02-12

## README

# child-process-debug #

Convenience methods for debugging child processes in Node.JS. Child processes will be started with `--debug` if the
parent was started with `--debug` and the children will each get their own increasing port number based off the 
parent's port number. The default port is 5858. If you add `--debug-brk` that will also get passed to the children.

## Example ##
```JS
var childProcessDebug = require('child-process-debug');

for (var i = 0; i < 4; i++) {
    //if this script wasn't run with --debug this will spawn node example.js [0-3]
    //if this script was run with --debug, this will spawn node --debug=[5859-5862] example.js [0-3]
    childProcessDebug.spawn(['example.js', i]);
}
```

## Methods ##

### spawn([command][, args][, options]) ###
This takes the exact same arguments as `child_process.spawn` and if the parent had debugging turned on (via --debug),
it'll turn on debugging for the spawned child. `command` is also optional (unlike `child_process.spawn`) and defaults
to `process.execPath`.

The ChildProcess returned from spawn will have a property called `debugPort` indicating the debug port chosen for that
child or undefined.

### fork(modulePath [, args][, options]) ###
This takes the exact same arguments as `child_process.fork` and if the parent had debugging turned on (via --debug),
it'll turn on debugging for the spawned child. Return is the same as `spawn` above.

### nextPort() ###
Returns the next debug port that comes after the current process's debug port. If the current process doesn't have
debug turned on then this will return undefined. This is useful if you're not using `spawn` and want to specify the
`--debug=port` argument yourself.

### exitWithParent(child) ###
Kill's the spawned child when the parent dies. This will not work if the parent is killed with SIGKILL.

### port() ###
Returns the current process's debug port or undefined if debug is not turned on.

### debugBreak() ###
Returns true if the current process has the flag `--debug-brk`.

By [James Hartig](https://github.com/fastest963/)

---
_Source: https://npm.io/package/child-process-debug · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
