Skip to content
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.

Commit

Permalink
Source formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
henvic committed Sep 19, 2015
1 parent d508362 commit 2a6a79a
Show file tree
Hide file tree
Showing 25 changed files with 369 additions and 369 deletions.
20 changes: 10 additions & 10 deletions lib/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ var configs = require('./configs'),

// -- Config -------------------------------------------------------------------

exports.clone = function(o) {
exports.clone = function (o) {
return JSON.parse(JSON.stringify(o));
};

// -- Utils --------------------------------------------------------------------

exports.load = function() {
exports.load = function () {
var config = configs.getConfig();

exports.github = new Github({
Expand All @@ -36,7 +36,7 @@ exports.load = function() {
});
};

exports.asyncReadPackages = function(callback) {
exports.asyncReadPackages = function (callback) {
function async(err, data) {
if (err) {
throw err;
Expand All @@ -47,13 +47,13 @@ exports.asyncReadPackages = function(callback) {

fs.readFile(path.join(__dirname, '..', 'package.json'), async);

configs.getPlugins().forEach(function(plugin) {
configs.getPlugins().forEach(function (plugin) {
fs.readFile(path.join(
configs.getNodeModulesGlobalPath(), plugin, 'package.json'), async);
});
};

exports.notifyVersion = function(pkg) {
exports.notifyVersion = function (pkg) {
var notifier = updateNotifier({pkg: pkg}),
update,
track = 'notify/';
Expand All @@ -69,11 +69,11 @@ exports.notifyVersion = function(pkg) {
}
};

exports.checkVersion = function() {
exports.checkVersion = function () {
exports.asyncReadPackages(exports.notifyVersion);
};

exports.expandAliases = function(options) {
exports.expandAliases = function (options) {
var config = configs.getConfig();

if (config.alias) {
Expand All @@ -83,13 +83,13 @@ exports.expandAliases = function(options) {
}
};

exports.find = function(filepath, opt_pattern) {
return fs.readdirSync(filepath).filter(function(file) {
exports.find = function (filepath, opt_pattern) {
return fs.readdirSync(filepath).filter(function (file) {
return (opt_pattern || /.*/).test(file);
});
};

exports.getUser = function() {
exports.getUser = function () {
return configs.getConfig().github_user;
};

Expand Down
14 changes: 7 additions & 7 deletions lib/cmd-anonymizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ function CmdAnonymizer(commandDetails, redaction) {
this.shorthands = commandDetails.shorthands;
}

CmdAnonymizer.prototype.extractArgument = function(word) {
CmdAnonymizer.prototype.extractArgument = function (word) {
return word.replace(/-{0,2}/, '');
};

CmdAnonymizer.prototype.isOptionValue = function(option, value) {
CmdAnonymizer.prototype.isOptionValue = function (option, value) {
var choice = this.options[option],
booleans = ['true', 'false'];

Expand All @@ -30,17 +30,17 @@ CmdAnonymizer.prototype.isOptionValue = function(option, value) {
(typeof choice === 'string' && choice === value));
};

CmdAnonymizer.prototype.isValueInOptions = function(options, value) {
CmdAnonymizer.prototype.isValueInOptions = function (options, value) {
if (!(options instanceof Array)) {
return this.isOptionValue(options, value);
}

return options.some(function(each) {
return options.some(function (each) {
return this.isOptionValue(this.extractArgument(each), value);
}, this);
};

CmdAnonymizer.prototype.classify = function(word) {
CmdAnonymizer.prototype.classify = function (word) {
var arg = this.extractArgument(word),
whitelist = ['verbose', 'no-hooks'];

Expand Down Expand Up @@ -79,7 +79,7 @@ CmdAnonymizer.prototype.classify = function(word) {
this.last = undefined;
};

CmdAnonymizer.prototype.resolve = function(cmd) {
CmdAnonymizer.prototype.resolve = function (cmd) {
// quasi-strict white list approach (best-effort)

this.invoked.push(cmd.shift());
Expand All @@ -89,7 +89,7 @@ CmdAnonymizer.prototype.resolve = function(cmd) {
return this.invoked;
};

CmdAnonymizer.prototype.resolveToString = function(cmd) {
CmdAnonymizer.prototype.resolveToString = function (cmd) {
return this.resolve(cmd).join(' ');
};

Expand Down
16 changes: 8 additions & 8 deletions lib/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var async = require('async'),

function hasCommandInOptions(commands, options) {
if (commands) {
return commands.some(function(c) {
return commands.some(function (c) {
return options[c] !== undefined;
});
}
Expand Down Expand Up @@ -60,7 +60,7 @@ function findCommand(name) {
}
else {
commandFiles = base.find(commandDir, /\.js$/i);
commandFiles.every(function(file) {
commandFiles.every(function (file) {
commandPath = path.join(commandDir, file);
Command = require(commandPath).Impl;

Expand Down Expand Up @@ -108,20 +108,20 @@ exports.setUp = function () {
remain = parsed.argv.remain,
cooked = parsed.argv.cooked;

operations.push(function(callback) {
operations.push(function (callback) {
base.checkVersion();

if (tracker.optOut !== undefined) {
callback();
return;
}

tracker.askPermission(null, function() {
tracker.askPermission(null, function () {
callback();
});
});

operations.push(function(callback) {
operations.push(function (callback) {
var module = remain[0];

if (cooked[0] === '--version' || cooked[0] === '-v') {
Expand Down Expand Up @@ -161,7 +161,7 @@ exports.setUp = function () {
}
});

async.series(operations, function() {
async.series(operations, function () {
var iterativeValues,
remoteUrl = git.getRemoteUrl(options.remote);

Expand Down Expand Up @@ -190,7 +190,7 @@ exports.setUp = function () {
// present, assume [undefined] in order to initialize the loop.
iterativeValues = options[iterative] || [undefined];

iterativeValues.forEach(function(value) {
iterativeValues.forEach(function (value) {
options = base.clone(options);

// Value can be undefined when the command doesn't have a iterative
Expand All @@ -206,7 +206,7 @@ exports.setUp = function () {
});
};

exports.run = function() {
exports.run = function () {
if (!fs.existsSync(configs.getUserHomePath())) {
configs.createGlobalConfig();
}
Expand Down
12 changes: 6 additions & 6 deletions lib/cmds/alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Alias.DETAILS = {
'r': ['--remove'],
'u': ['--user']
},
payload: function(payload, options) {
payload: function (payload, options) {
if (payload[0]) {
options.add = payload[0];
options.user = payload[1];
Expand All @@ -58,7 +58,7 @@ Alias.DETAILS = {

// -- Commands -------------------------------------------------------------------------------------

Alias.prototype.run = function() {
Alias.prototype.run = function () {
var instance = this,
options = instance.options;

Expand All @@ -72,7 +72,7 @@ Alias.prototype.run = function() {
}

if (options.list) {
instance.list(function(err, data) {
instance.list(function (err, data) {
var item;

for (item in data) {
Expand All @@ -89,18 +89,18 @@ Alias.prototype.run = function() {
}
};

Alias.prototype.add = function() {
Alias.prototype.add = function () {
var instance = this,
options = instance.options;

configs.writeGlobalConfig('alias.' + options.add, options.user);
};

Alias.prototype.list = function(opt_callback) {
Alias.prototype.list = function (opt_callback) {
opt_callback && opt_callback(null, config.alias);
};

Alias.prototype.remove = function() {
Alias.prototype.remove = function () {
var instance = this,
options = instance.options;

Expand Down
36 changes: 18 additions & 18 deletions lib/cmds/gists.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ Gists.DETAILS = {
'p': ['--private'],
'u': ['--user']
},
payload: function(payload, options) {
payload: function (payload, options) {
options.list = true;
}
};

// -- Commands -------------------------------------------------------------------------------------

Gists.prototype.run = function() {
Gists.prototype.run = function () {
var instance = this,
operations,
options = instance.options;
Expand All @@ -84,7 +84,7 @@ Gists.prototype.run = function() {
}

if (options.delete) {
hooks.invoke('gists.delete', instance, function(afterHooksCallback) {
hooks.invoke('gists.delete', instance, function (afterHooksCallback) {
logger.log('Deleting gist ' + logger.colors.green(options.loggedUser + '/' + options.delete));

inquirer.prompt(
Expand All @@ -94,9 +94,9 @@ Gists.prototype.run = function() {
message: 'Are you sure? This action CANNOT be undone. [y/N]',
name: 'confirmation'
}
], function(answers) {
], function (answers) {
if (answers.confirmation.toLowerCase() === 'y') {
instance.delete(options.delete, function(err) {
instance.delete(options.delete, function (err) {
if (err) {
logger.error('Can\'t delete gist.');
return;
Expand All @@ -113,10 +113,10 @@ Gists.prototype.run = function() {
}

if (options.fork) {
hooks.invoke('gists.fork', instance, function(afterHooksCallback) {
hooks.invoke('gists.fork', instance, function (afterHooksCallback) {
logger.log('Forking gist on ' + logger.colors.green(options.loggedUser));

instance.fork(options.fork, function(err, gist) {
instance.fork(options.fork, function (err, gist) {
if (err) {
logger.error(JSON.parse(err.message).message);
return;
Expand All @@ -131,7 +131,7 @@ Gists.prototype.run = function() {
if (options.list) {
logger.log('Listing gists for ' + logger.colors.green(options.user));

instance.list(options.user, function(err) {
instance.list(options.user, function (err) {
if (err) {
logger.error('Can\'t list gists for ' + options.user + '.');
return;
Expand All @@ -140,7 +140,7 @@ Gists.prototype.run = function() {
}

if (options.new) {
hooks.invoke('gists.new', instance, function(afterHooksCallback) {
hooks.invoke('gists.new', instance, function (afterHooksCallback) {
var privacy = (options.private) ? 'private' : 'public';

operations = [];
Expand All @@ -149,7 +149,7 @@ Gists.prototype.run = function() {
logger.log('Creating ' + logger.colors.magenta(privacy) + ' gist on ' +
logger.colors.green(options.loggedUser));

instance.new(options.new, options.content, function(err, gist) {
instance.new(options.new, options.content, function (err, gist) {
if (gist) {
options.id = gist.id;
}
Expand All @@ -167,40 +167,40 @@ Gists.prototype.run = function() {
}
};

Gists.prototype.browser = function(gist) {
Gists.prototype.browser = function (gist) {
openUrl('https://gist.github.com/' + gist);
};

Gists.prototype.delete = function(id, opt_callback) {
Gists.prototype.delete = function (id, opt_callback) {
var payload = {
id: id
};

base.github.gists.delete(payload, opt_callback);
};

Gists.prototype.fork = function(id, opt_callback) {
Gists.prototype.fork = function (id, opt_callback) {
var payload = {
id: id
};

base.github.gists.fork(payload, opt_callback);
};

Gists.prototype.list = function(user, opt_callback) {
Gists.prototype.list = function (user, opt_callback) {
var instance = this,
payload;

payload = {
user: user
};

base.github.gists.getFromUser(payload, function(err, gists) {
base.github.gists.getFromUser(payload, function (err, gists) {
instance.listCallback_(err, gists, opt_callback);
});
};

Gists.prototype.listCallback_ = function(err, gists, opt_callback) {
Gists.prototype.listCallback_ = function (err, gists, opt_callback) {
var instance = this,
options = instance.options;

Expand All @@ -209,7 +209,7 @@ Gists.prototype.listCallback_ = function(err, gists, opt_callback) {
}

if (gists && gists.length > 0) {
gists.forEach(function(gist) {
gists.forEach(function (gist) {
logger.log(logger.colors.yellow(gist.owner.login + '/' + gist.id) +
' ' + logger.getDuration(gist.updated_at));

Expand All @@ -224,7 +224,7 @@ Gists.prototype.listCallback_ = function(err, gists, opt_callback) {
}
};

Gists.prototype.new = function(name, content, opt_callback) {
Gists.prototype.new = function (name, content, opt_callback) {
var instance = this,
file = {},
options = instance.options,
Expand Down
Loading

0 comments on commit 2a6a79a

Please sign in to comment.