Permalink
Browse files

fix all jshint errors

  • Loading branch information...
1 parent 47ae877 commit 4e64f2674ecad1f5b99b7288ae499fe36761efcf @lloyd lloyd committed Sep 20, 2013
Showing with 101 additions and 108 deletions.
  1. +12 −9 lib/aws.js
  2. +3 −2 lib/config.js
  3. +15 −17 lib/dns.js
  4. +12 −12 lib/git.js
  5. +4 −4 lib/hooks.js
  6. +3 −2 lib/key.js
  7. +4 −4 lib/sec.js
  8. +27 −26 lib/ssh.js
  9. +21 −32 lib/vm.js
View
@@ -2,35 +2,38 @@ const
amazonEc2 = require('awssum-amazon-ec2'),
amazonRoute53 = require('awssum-amazon-route53'),
NiceRoute53 = require('nice-route53'),
-config = require('./config.js');
+config = require('./config.js'),
+jsel = require('JSONSelect');
function createEc2Client(region) {
return new amazonEc2.Ec2({
- accessKeyId: process.env['AWS_ID'],
- secretAccessKey: process.env['AWS_SECRET'],
+ accessKeyId: process.env.AWS_ID,
+ secretAccessKey: process.env.AWS_SECRET,
region: region || amazonEc2.US_EAST_1, // default
});
}
function createRoute53Client() {
return new amazonRoute53.Route53({
- accessKeyId: process.env['AWS_ID'],
- secretAccessKey: process.env['AWS_SECRET'],
+ accessKeyId: process.env.AWS_ID,
+ secretAccessKey: process.env.AWS_SECRET,
});
}
function createNiceRoute53Client() {
return new NiceRoute53({
- accessKeyId: process.env['AWS_ID'],
- secretAccessKey: process.env['AWS_SECRET'],
+ accessKeyId: process.env.AWS_ID,
+ secretAccessKey: process.env.AWS_SECRET,
});
}
// make an error from an Amazon error
exports.makeError = function(err) {
var e;
console.log(err.Body.Response);
- try { e = err.Body.Response.Errors.Error.Code + ": " + err.Body.Response.Errors.Error.Message } catch(ex) {};
+ try {
+ e = err.Body.Response.Errors.Error.Code + ": " + err.Body.Response.Errors.Error.Message;
+ } catch(ex) { }
return e || err;
};
@@ -50,7 +53,7 @@ exports.createClients = function(region) {
exports.allocateEC2Client = function(region) {
return createEc2Client(region);
-}
+};
exports.zones = function(cb) {
exports.client.DescribeRegions(function(err, regions) {
View
@@ -2,8 +2,9 @@ const fs = require('fs'),
path = require('path');
exports.get = function() {
+ var awsboxJson;
try {
- var awsboxJson = JSON.parse(fs.readFileSync("./.awsbox.json"));
+ awsboxJson = JSON.parse(fs.readFileSync("./.awsbox.json"));
} catch(e) {
process.stderr.write('ERRORE FATALE: ' + e + "\n");
process.exit(1);
@@ -12,7 +13,7 @@ exports.get = function() {
return awsboxJson;
};
-exports.region = process.env['AWS_REGION'] || 'us-east-1';
+exports.region = process.env.AWS_REGION || 'us-east-1';
exports.defaultImagesPath = path.join(__dirname, '..', "defaultImages.json");
View
@@ -6,34 +6,37 @@ jsel = require('JSONSelect'),
async = require('async');
exports.updateRecord = function (hostname, ip, cb) {
- if (!hostname || !ip) return process.nextTick(function() { cb('No hostname/ip address provided') });
+ if (!hostname || !ip) {
+ return process.nextTick(function() {
+ cb('No hostname/ip address provided');
+ });
+ }
// split hostname into two (e.g. blah.example.org -> blah and example.org)
- var subdomain = hostname.split('.')[0];
var domain = hostname.split('.').slice(1).join('.');
// firstly, get the zoneInfo
aws.niceRoute53.zoneInfo(domain, function(err, zoneInfo) {
if (err) return cb(err);
var args = {
- zoneId : zoneInfo.zoneId,
- name : hostname,
- type : 'A',
- ttl : 60,
- values : [ ip ],
+ zoneId : zoneInfo.zoneId,
+ name : hostname,
+ type : 'A',
+ ttl : 60,
+ values : [ ip ]
};
aws.niceRoute53.setRecord(args, 10, cb);
});
};
exports.listDomains = function(cb) {
aws.niceRoute53.zones(cb);
-}
+};
exports.listHosts = function(domainName, cb) {
aws.niceRoute53.records(domainName, cb);
-}
+};
exports.findByIP = function (ip, cb) {
var found = [];
@@ -74,9 +77,7 @@ exports.findByIP = function (ip, cb) {
};
exports.deleteRecord = function (hostname, cb) {
- if (!hostname) return process.nextTick(function() {
- cb('No hostname provided');
- });
+ if (!hostname) throw new Error('No hostname provided');
// split hostname into two (e.g. blah.example.org -> blah and example.org)
var subdomain = hostname.split('.')[0];
@@ -98,9 +99,7 @@ exports.deleteRecord = function (hostname, cb) {
};
exports.inUse = function(hostname, cb) {
- if (!hostname) return process.nextTick(function() {
- cb('No hostname provided');
- });
+ if (!hostname) throw new Error('No hostname provided');
var found;
@@ -120,7 +119,6 @@ exports.inUse = function(hostname, cb) {
if ( record.type !== 'A' ) return;
// check if this record.name is the same as the one we want
- var thisName = record.name;
if ( record.name === hostname ) {
found = {
name : record.name,
@@ -139,4 +137,4 @@ exports.inUse = function(hostname, cb) {
}
);
});
-}
+};
View
@@ -7,15 +7,15 @@ path = require('path');
// This prevents the user from being required to enter their password on a git
// push
function getEnv(extraEnv) {
- var env = {};
+ var key, env = {};
// copy over the original environment
- for(var key in process.env) {
+ for(key in process.env) {
env[key] = process.env[key];
}
// add each item in extraEnv
- for(var key in extraEnv) {
+ for(key in extraEnv) {
env[key] = extraEnv[key];
}
@@ -39,8 +39,8 @@ exports.removeRemote = function(name, host, cb) {
var remotes = {};
r.split('\n').forEach(function(line) {
if (!line.length) return;
- var line = line.split('\t');
- if (!line.length == 2) return;
+ line = line.split('\t');
+ if (line.length !== 2) return;
remotes[line[0]] = line[1].split(" ")[0];
});
if (remotes[name] && remotes[name] === desired) {
@@ -102,8 +102,8 @@ exports.push = function(dir, host, pr, cb) {
});
p.stdout.on('data', function(c) { splitAndEmit(c, pr); });
p.stderr.on('data', function(c) { splitAndEmit(c, pr); });
- p.on('exit', function(code, signal) {
- return cb(code != 0);
+ p.on('exit', function(code) {
+ return cb(code !== 0);
});
};
@@ -120,10 +120,10 @@ exports.pull = function(dir, remote, branch, pr, cb) {
p.stdout.on('data', function(c) { splitAndEmit(c, pr); });
p.stderr.on('data', function(c) { splitAndEmit(c, pr); });
- p.on('exit', function(code, signal) {
- return cb(code != 0);
+ p.on('exit', function(code) {
+ return cb(code !== 0);
});
-}
+};
exports.init = function(dir, cb) {
var p = spawn('git', [ 'init' ], {
@@ -132,7 +132,7 @@ exports.init = function(dir, cb) {
GIT_WORK_TREE: dir
})
});
- p.on('exit', function(code, signal) {
- return cb(code != 0);
+ p.on('exit', function(code) {
+ return cb(code !== 0);
});
};
View
@@ -24,7 +24,7 @@ exports.runRemoteHook = function(which, deets, cb) {
console.log(" ... running remote", which, "hook");
}
ssh.runScript(deets.ipAddress, cmd, cb);
-}
+};
exports.runLocalHook = function(which, deets, cb) {
var cmd = getLocalHook(which);
@@ -33,7 +33,7 @@ exports.runLocalHook = function(which, deets, cb) {
}
// let each local hook now what the remote AWS host is.
- process.env['AWS_IP_ADDRESS'] = deets.ipAddress;
- var childProcess = child_process.exec(cmd, cb);
-}
+ process.env.AWS_IP_ADDRESS = deets.ipAddress;
+ child_process.exec(cmd, cb);
+};
View
@@ -7,7 +7,7 @@ jsel = require('JSONSelect'),
crypto = require('crypto'),
ssh = require('./ssh.js');
-const keyPath = process.env['AWSBOX_PUBKEY'] || path.join(process.env['HOME'], ".ssh", "id_rsa.pub");
+const keyPath = process.env.AWSBOX_PUBKEY || path.join(process.env.HOME, ".ssh", "id_rsa.pub");
exports.read = function(cb) {
fs.readFile(keyPath, cb);
@@ -38,11 +38,12 @@ exports.getName = function(cb) {
// key isn't yet installed!
exports.read(function(err, key) {
+ if (err) return cb(err);
// ImportKeyPair
aws.client.ImportKeyPair({
KeyName: keyName,
PublicKeyMaterial: new Buffer(key).toString('base64')
- }, function(err, result) {
+ }, function(err) {
if (err) return cb(aws.makeError(err));
cb(null, keyName);
});
View
@@ -1,5 +1,5 @@
const
-aws = require('./aws.js');
+aws = require('./aws.js'),
jsel = require('JSONSelect'),
key = require('./key.js');
@@ -26,7 +26,7 @@ exports.getName = function(name, cb) {
aws.client.CreateSecurityGroup({
GroupName: groupName,
GroupDescription: 'A security group for awsbox deployments'
- }, function(err, r) {
+ }, function(err) {
if (err) {
return cb(createError('failed to create security group', err));
}
@@ -54,8 +54,8 @@ exports.getName = function(name, cb) {
},
],
}, function(err, r) {
- if (err) return cb(createError('failed to create security group', err));
- cb(null, r.groupName);
+ if (err) return cb(createError('failed to create security group', err));
+ cb(null, r.groupName);
});
});
} else if (err) {
Oops, something went wrong.

0 comments on commit 4e64f26

Please sign in to comment.