Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pawsong/childminder
Promise based child process manager for development
https://github.com/pawsong/childminder
Last synced: about 5 hours ago
JSON representation
Promise based child process manager for development
- Host: GitHub
- URL: https://github.com/pawsong/childminder
- Owner: pawsong
- Created: 2016-01-07T08:36:57.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-04-04T09:22:36.000Z (over 8 years ago)
- Last Synced: 2024-10-14T06:38:22.682Z (about 1 month ago)
- Language: TypeScript
- Homepage:
- Size: 17.6 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# childminder
`childminder` is a promise based child process manager for development.
[![NPM Version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]```typescript
import { Childminder } from 'childminder';const cm = new Childminder();
const child = cm.create('echo', ['Hello, world'], {
prefix: 'greeting',
prefixColor: 12,
});child.restart();
```## Features
- Colorful console prefix
- Preserve child process console message color
- Handle multiple processes## Motivation
[nodemon][nodemon] is a useful tool in node.js server
programming. It watches file changes and restarts node.js process automatically. If we use transpilers like [Babel][Babel], [CoffeeScript][coffeeScript] or [TypeScript][TypeScript], however, process should not restart when file changes but when transpilation is completed. Maybe in this case, we should monitor events from transpiler and reload process manually.`childminder` is yet another tool for development like [nodemon][nodemon], but does not watch file changes. When using `childminder`, you should call `childminder` process restart function manually, which looks cumbersome but indeed is a clear way.
## API
### Class: `Childminder`
Process manager that contains multiple Child instances.
`Childminder#create(command[, args][, options]) => Child`
Create `Child` instance.
- `command` *String* The command to run
- `args` *Array* List of string arguments
- `options` *Object*
- `cwd` *String* Current working directory of the child process
- `env` *Object* Environment key-value pairs
- `prefix` *String* `stdout` message prefix
- `prefixColor` *Number* Prefix xTerm colors
- `stdout` *stream.Writable* Child's stdout stream (Default: `process.stdout`)
- `lazy` *Boolean* If true, `Child` process does not start running when created (Default: `false`)
- returns `Child` instance.### Class: `Child`
Thin wrapper of node.js ChildProcess object, which supports restart. `Child` instance is created by `Childminder#create` method.
`Child#startOrRestart() => Promise`
Starts or restarts child process. Returned promise is resolved when the previous process exits and new process gets started.
`Child#restart() => Promise`
Restarts running child process. Returned promise is resolved when the previous process exits and new process gets started.
`Child#waitForExit() => Promise`
Wait for child process to terminate. Returned promise is resolved when the process exits.
`Child#isRunning() => boolean`
Returns if the child process is running.
`Child#kill(signal = 'SIGHUP') => Promise`
Kill child process and wait for it to terminate. Returned promise is resolved when the process exits.
## License
MIT
[npm-image]: https://img.shields.io/npm/v/childminder.svg
[npm-url]: https://npmjs.org/package/childminder
[travis-image]: https://img.shields.io/travis/pawsong/childminder/master.svg
[travis-url]: https://travis-ci.org/pawsong/childminder[nodemon]: https://github.com/remy/nodemon
[Babel]: https://github.com/babel/babel
[CoffeeScript]: https://github.com/jashkenas/coffeescript
[TypeScript]: https://github.com/Microsoft/TypeScript