Permalink
Browse files

Rename bag variable to cli/req since it's likely multiple bagof* modu…

…les are used on the same file.
  • Loading branch information...
1 parent bb79669 commit 94f2169592d82de0769338d90f005463b9b863e9 @cliffano committed Aug 24, 2013
Showing with 89 additions and 89 deletions.
  1. +15 −15 lib/cli.js
  2. +10 −10 lib/jenkins.js
  3. +29 −29 test/cli.js
  4. +35 −35 test/jenkins.js
View
@@ -6,8 +6,8 @@ const COLORS = {
};
var _ = require('lodash'),
- bag = require('bagofcli'),
BuildLight = require('./notifiers/buildlight'),
+ cli = require('bagofcli'),
colors = require('colors'),
commander = require('commander'),
irc = require('./irc'),
@@ -49,7 +49,7 @@ function _build(jobName, params, args) {
if (args.console) {
cb = function (err, result) {
if (err) {
- bag.exit(err, result);
+ cli.exit(err, result);
} else {
console.log(message, jobName);
// wait for pending period before calling console
@@ -59,7 +59,7 @@ function _build(jobName, params, args) {
}
};
} else {
- cb = bag.exitCb(null, function (result) {
+ cb = cli.exitCb(null, function (result) {
console.log(message, jobName);
});
}
@@ -72,21 +72,21 @@ function _build(jobName, params, args) {
function _buildAll(args) {
function execCb(jenkins) {
- jenkins.filteredBuild(null, bag.exit);
+ jenkins.filteredBuild(null, cli.exit);
}
__exec(args, execCb);
}
function _buildFail(args) {
function execCb(jenkins) {
- jenkins.filteredBuild({ status: 'FAIL' }, bag.exit);
+ jenkins.filteredBuild({ status: 'FAIL' }, cli.exit);
}
__exec(args, execCb);
}
function _console(jobName, args) {
function execCb(jenkins) {
- jenkins.console(jobName, bag.exit);
+ jenkins.console(jobName, cli.exit);
}
__exec(args, execCb);
}
@@ -95,7 +95,7 @@ function _stop(jobName, args) {
function execCb(jenkins) {
jenkins.stop(
jobName,
- bag.exitCb(null, function (result) {
+ cli.exitCb(null, function (result) {
console.log(text.__('Job %s was stopped successfully'), jobName);
})
);
@@ -105,7 +105,7 @@ function _stop(jobName, args) {
function _dashboard(args) {
function execCb(jenkins) {
- jenkins.dashboard(bag.exitCb(null, function (result) {
+ jenkins.dashboard(cli.exitCb(null, function (result) {
if (result.length === 0) {
console.log(text.__('Jobless Jenkins'));
} else {
@@ -127,7 +127,7 @@ function _discover(host, args) {
}
function execCb(jenkins) {
- jenkins.discover(host, bag.exitCb(null, function (result) {
+ jenkins.discover(host, cli.exitCb(null, function (result) {
console.log(text.__('Jenkins ver. %s is running on %s'),
result.hudson.version[0],
(result.hudson.url && result.hudson.url[0]) ? result.hudson.url[0] : host);
@@ -138,7 +138,7 @@ function _discover(host, args) {
function _executor(args) {
function execCb(jenkins) {
- jenkins.executor(bag.exitCb(null, function (result) {
+ jenkins.executor(cli.exitCb(null, function (result) {
if (!_.isEmpty(_.keys(result))) {
_.keys(result).forEach(function (computer) {
console.log('+ ' + computer);
@@ -160,7 +160,7 @@ function _executor(args) {
function _job(name, args) {
function execCb(jenkins) {
- jenkins.job(name, bag.exitCb(null, function (result) {
+ jenkins.job(name, cli.exitCb(null, function (result) {
var status = text.__(result.status),
color = [COLORS[result.status] || 'grey'];
console.log('%s | %s', name, status[color]);
@@ -174,7 +174,7 @@ function _job(name, args) {
function _queue(args) {
function execCb(jenkins) {
- jenkins.queue(bag.exitCb(null, function (result) {
+ jenkins.queue(cli.exitCb(null, function (result) {
if (result.length === 0) {
console.log(text.__('Queue is empty'));
} else {
@@ -189,7 +189,7 @@ function _queue(args) {
function _version(args) {
function execCb(jenkins) {
- jenkins.version(bag.exitCb(null, function (result) {
+ jenkins.version(cli.exitCb(null, function (result) {
console.log(text.__('Jenkins ver. %s', result));
}));
}
@@ -208,7 +208,7 @@ function _feed(args) {
};
function execCb(jenkins) {
- jenkins.feed(opts, bag.exitCb(null, function (result) {
+ jenkins.feed(opts, cli.exitCb(null, function (result) {
result.forEach(function (article) {
console.log(article.title);
});
@@ -274,7 +274,7 @@ function exec() {
}
};
- bag.command(__dirname, actions);
+ cli.command(__dirname, actions);
}
exports.exec = exec;
View
@@ -1,12 +1,12 @@
var _ = require('lodash'),
async = require('async'),
- bag = require('bagofrequest'),
commander = require('commander'),
ConsoleStream = require('./consolestream'),
cron = require('cron'),
dgram = require('dgram'),
feedparser = require('feedparser'),
p = require('path'),
+ req = require('bagofrequest'),
request = require('request'),
text = require('bagoftext'),
xml2js = require('xml2js');
@@ -73,7 +73,7 @@ Jenkins.prototype.build = function (jobName, params, cb) {
this.opts.handlers[404] = _notFound;
this.opts.handlers[405] = _paramsRequire; // backward compatibility (< v1.5xx)
- bag.request(method, this.url + '/job/' + jobName + '/build', this.opts, cb);
+ req.request(method, this.url + '/job/' + jobName + '/build', this.opts, cb);
};
/**
@@ -150,7 +150,7 @@ Jenkins.prototype.consoleStream = function(jobName, opts, cb) {
url: url,
qs: { start: parseInt(result.headers['x-text-size'], 10) }
},
- envProxy = bag.proxy(url);
+ envProxy = req.proxy(url);
if (envProxy) {
params.proxy = envProxy;
}
@@ -181,7 +181,7 @@ Jenkins.prototype.consoleStream = function(jobName, opts, cb) {
this.opts.handlers[404] = _notFound;
process.nextTick(function () {
- bag.request('get', url, self.opts, cb);
+ req.request('get', url, self.opts, cb);
});
return stream;
@@ -218,7 +218,7 @@ Jenkins.prototype.stop = function (jobName, cb) {
this.opts.handlers[200] = _success;
this.opts.handlers[404] = _notFound;
- bag.request('post', this.url + '/job/' + jobName + '/lastBuild/stop', this.opts, cb);
+ req.request('post', this.url + '/job/' + jobName + '/lastBuild/stop', this.opts, cb);
};
/**
@@ -254,7 +254,7 @@ Jenkins.prototype.dashboard = function (opts, cb) {
this.opts.handlers[200] = _success;
- bag.request('get', url, this.opts, cb);
+ req.request('get', url, this.opts, cb);
};
/**
@@ -326,7 +326,7 @@ Jenkins.prototype.executor = function (cb) {
this.opts.handlers[200] = _success;
- bag.request('get', this.url + '/computer/api/json', this.opts, cb);
+ req.request('get', this.url + '/computer/api/json', this.opts, cb);
};
/**
@@ -358,7 +358,7 @@ Jenkins.prototype.job = function (name, cb) {
this.opts.handlers[200] = _success;
this.opts.handlers[404] = _notFound;
- bag.request('get', this.url + '/job/' + name + '/api/json', this.opts, cb);
+ req.request('get', this.url + '/job/' + name + '/api/json', this.opts, cb);
};
/**
@@ -382,7 +382,7 @@ Jenkins.prototype.queue = function (cb) {
this.opts.handlers[200] = _success;
- bag.request('get', this.url + '/queue/api/json', this.opts, cb);
+ req.request('get', this.url + '/queue/api/json', this.opts, cb);
};
/**
@@ -403,7 +403,7 @@ Jenkins.prototype.version = function (cb) {
this.opts.handlers[200] = _success;
- bag.request('head', this.url, this.opts, cb);
+ req.request('head', this.url, this.opts, cb);
};
/**
Oops, something went wrong.

0 comments on commit 94f2169

Please sign in to comment.