UNPKG

894 BJavaScriptView Raw
1var dataflows = require('dataflo.ws');
2var minimist = require('minimist');
3
4module.exports = {
5 launchContext: function () {
6 return {
7 token: process.argv[3],
8 param: process.argv[4],
9 args: minimist(process.argv.slice(4))
10 };
11 },
12 launch: function (conf) {
13 var tokenDFConf = conf.initiator.token;
14
15 var tokenIClass = dataflows.initiator ('token');
16
17 if ('function' == typeof tokenIClass) {
18 var processor = new tokenIClass (tokenDFConf);
19 } else {
20 console.error('Cannot load initiator "%s"', 'callback');
21 }
22
23 var flow = processor.process (this.launchContext().token, {
24 templates: {},
25 request: {
26 param: this.launchContext().param,
27 args: this.launchContext().args
28 },
29 autoRun: false
30 });
31
32 flow.on ('completed', function (flow) {
33 process.kill();
34 });
35 flow.on ('failed', function (flow) {
36 process.kill();
37 });
38
39 flow.run ();
40
41 }
42}