This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

crocess

1.0.22 • Public • Published

Crocess

npm Travis license

Make your command-line programs be easily called by externals.

Links

Requirements

  • Node.js >= 6.0.0

Installation

$ npm install crocess

Quick Start

Learn more about Application

Create an application instance and return data to console:
var Application = require('crocess').Application;
 
new Application().boot(function () {
    console.log('Hello world!');
 
    return { 'foo': 'bar' };
});

You will see this on console:

Hello world!
>>>>>BEGIN_RESULT>>>>>{"foo":"bar"}
You can also return a Promise.
new Application().boot(function () {
    return Promise.resolve({"foo":"bar"});
});
 
// or using 'async/await'.
 
new Application().boot(async function () {
    return await Promise.resolve({"foo":"bar"});
});
 
// => >>>>>BEGIN_RESULT>>>>>{"foo":"bar"}

Get Parameters

You can pass the parameters as a json formatted string with the --parameters argument.

node example.js --parameters='{"name":"World"}'

Example:

new Application().boot(function () {
    return 'Hello ' + this.parameters.name;
});
 
// => >>>>>BEGIN_RESULT>>>>>Hello World

The parameters property will be empty when the --parameters argument not given.

Using Suite

Learn more about Suites

An example suite class:

var Application = require('crocess').Application;
var BaseSuite = require('crocess').Suite;
 
class Example extends BaseSuite
{
    /**
     * Start handle the suite.
     */
    handle() {
        console.log('Hello suite!');
 
        return 'foobar';
    }
}

Now, boot the suite:

new Application().boot(new Example);

You will see this on console:

Hello suite!
>>>>>BEGIN_RESULT>>>>>foobar

Another way to boot suites:

new Application().boot(function () {
    return new Example().boot(this);
});

If you need to passing something to the suite, a very straightforward way is override the constructor:

class Example extends BaseSuite
{
    constructor(foo) {
        super();
 
        this.foo = foo;
    }
}

Package Sidebar

Install

npm i crocess

Weekly Downloads

33

Version

1.0.22

License

MIT

Last publish

Collaborators

  • npm