node package manager

forrest

Forrest

Run pending scripts (services) in a child_process and talk to them (and kill those bastards)

How to use Forrest

import Forrest from 'forrest';

// run a simple command that exits by itself
Forrest.run('ls').then(output => console.log(output));

// run a service and do soemthing when ready
var service = Forrest.run(, {
	service: './my-server.js',
	expect: /listening on 3000/g,
});

// do something when the service is ready
service.then(() => console.log('MyServer is ready!'));

// do something else if the service fails
service.catch(err) => console.log('Error', err));

Options

service

expect

listenTo

[stdout|stderr]

some services send logs to stderr, strange but true!

cwd

(bool)failsOnError

listen to stderr and fail the promise if anything is sent here.

Methods

then()

catch()

stop()

gracefully stop the service, sends in a SIGTERM and return a Promise.

kill()

hard kill

Folder Structure

/src

Write here your ES6 source files.

/test

Write here your ES6 unit tests.

/lib

This is the target folder for ES5 transpiled files.

(ES6)          (ES5)
/src/foo.js -> /lib/foo.js

/coverage

This is the target folder for the test coverage report.

Provided Scripts

There are a couple of NPM scripts which make your developer life easier:

npm run build

It transpiles /src into ES5 compatible files in /lib.

npm run build:watch

It transpiles and monitor /src files for new changes.

npm lint

It checks your code for any possible problem or style errors accordingly to .eslintrc.

npm clean

It removes all the generated files in /lib and /coverage.

npm test

npm run test:watch

npm run test:cov

It runs the tests and produces a test coverage report in /coverage.