Skip to content

Commit b830218

Browse files
committed
[fix] Ensure forever script.js works
1 parent 285b659 commit b830218

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

lib/forever/cli.js

+24-4
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,19 @@ app.use(flatiron.plugins.cli, {
7474
usage: help
7575
});
7676

77+
var actions = [
78+
'start',
79+
'stop',
80+
'restart',
81+
'list',
82+
'config',
83+
'set',
84+
'clear',
85+
'logs',
86+
'columns',
87+
'cleanlogs'
88+
];
89+
7790
var argvOptions = cli.argvOptions = {
7891
'command': {alias: 'c'},
7992
'errFile': {alias: 'e'},
@@ -453,22 +466,29 @@ app.cmd('help', cli.help = function () {
453466
// Remark: this regex matches everything. It has to be added at the end to
454467
// make executing other commands possible.
455468
//
456-
app.cmd(/(.*)/, cli.start = function () {
457-
var file = require('optimist').argv._[0],
469+
cli.run = function () {
470+
var file = app.argv._[0],
458471
options = getOptions(file);
472+
459473
tryStart(file, options, function () {
460474
var monitor = forever.start(file, options);
461475
monitor.on('start', function () {
462476
forever.startServer(monitor);
463477
});
464478
});
465-
});
479+
};
466480

467481
cli.start = function () {
468482
if (app.config.get('help')) {
469483
return util.puts(help.join('\n'));
470484
}
471485

472-
app.init(app.start);
486+
app.init(function () {
487+
if (actions.indexOf(app.argv._[0]) === -1) {
488+
return cli.run();
489+
}
490+
491+
app.start();
492+
});
473493
};
474494

0 commit comments

Comments
 (0)