Skip to content

Commit

Permalink
[merge] A few random missed conflicts from git cherry-pick on 22 co…
Browse files Browse the repository at this point in the history
…mmits. oops.
  • Loading branch information
indexzero committed Nov 23, 2011
1 parent 60a576a commit 4ae63d0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 22 deletions.
18 changes: 14 additions & 4 deletions lib/forever/cli.js
Expand Up @@ -169,7 +169,8 @@ function getOptions(file) {
// Now we have to force optimist to reparse command line options because
// we've removed some before.
//
app.config.system.loadArgv();
app.config.system.reset();
app.config.system.loadSync();

[
'pidFile', 'logFile', 'errFile', 'watch', 'minUptime', 'appendLog',
Expand Down Expand Up @@ -433,6 +434,14 @@ app.cmd('columns set :value', cli.setColumns = function (columns) {
forever.config.saveSync();
});

//
// ### function help ()
// Shows help
//
app.cmd('help', cli.help = function () {
util.puts(help.join('\n'));
});

//
// ### function start (file)
// #### @file {string} Location of the script to spawn with forever
Expand All @@ -442,9 +451,10 @@ app.cmd('columns set :value', cli.setColumns = function (columns) {
// Remark: this regex matches everything. It has to be added at the end to
// make executing other commands possible.
//
app.cmd(/(.+)/, cli.start = function (file) {
tryStart(file, {}, function () {
var monitor = forever.start(file, {});
app.cmd(/(.*)/, cli.start = function (file) {
var options = getOptions(file);
tryStart(file, options, function () {
var monitor = forever.start(file, options);
monitor.on('start', function () {
forever.startServer(monitor);
});
Expand Down
41 changes: 23 additions & 18 deletions test/cli-test.js
Expand Up @@ -14,26 +14,11 @@ var fs = require('fs'),
rimraf = require('utile').rimraf,
forever = require('../lib/forever');

var script = path.join(__dirname, '..', 'examples', 'log-on-interval.js');
var script = path.join(__dirname, '..', 'examples', 'log-on-interval.js'),
options = ['--uid', 'itShouldNotGoToUIDField'];

vows.describe('forever/cli').addBatch({
'When using forever CLI': {
<<<<<<< HEAD
'and starting script using `forever start`': helpers.spawn(['start', script], {
'`forever.list` result': helpers.list({
'should contain spawned process': function (list) {
assert.isNotNull(list);
assert.lengthOf(list, 1);
assert.equal(list[0].command, 'node');
assert.equal(fs.realpathSync(list[0].file), fs.realpathSync(script));
helpers.assertStartsWith(list[0].logFile, forever.config.get('root'));
},
'and stopping it using `forever stop`': helpers.spawn(['stop', script], {
'`forever.list` result': helpers.list({
'should not contain previous process': function (list) {
assert.isNull(list);
}
=======
"when ~/.forever/sock is empty": {
topic: function () {
rimraf(path.join(process.env.HOME, '.forever', 'sock'), this.callback);
Expand All @@ -52,11 +37,31 @@ vows.describe('forever/cli').addBatch({
assert.isNull(list);
}
})
>>>>>>> b622bf1... [test fix] Since forever.kill is async, use `async.forEach`. Update test/cli-test.js to rimraf ~/.forever temporarily
})
})
})
}
}
}).addBatch({
'When using forever CLI': {
'and starting script using `forever start` with arguments': helpers.spawn(['start', script].concat(options), {
'`forever.list` result': helpers.list({
'should contain spawned process with proper options': function (list) {
helpers.assertList(list);
assert.notEqual(list[0].uid, 'itShouldNotGoToUIDField');
assert.deepEqual(list[0].options, options);
}
})
})
}
}).addBatch({
'When testing forever CLI': {
'necessary cleanup': {
topic: function () {
forever.stopAll().on('stopAll', this.callback.bind({}, null));
},
'should take place': function () {}
}
}
}).export(module);

5 changes: 5 additions & 0 deletions test/helpers.js
Expand Up @@ -66,4 +66,9 @@ helpers.list = function (options) {

helpers.assertStartsWith = function (string, substring) {
assert.equal(string.slice(0, substring.length), substring);
};

helpers.assertList = function (list) {
assert.isNotNull(list);
assert.lengthOf(list, 1);
};

0 comments on commit 4ae63d0

Please sign in to comment.