Skip to content

Commit

Permalink
Apply style guide
Browse files Browse the repository at this point in the history
  • Loading branch information
SBoudrias committed Dec 30, 2013
1 parent 7550786 commit 34441c2
Show file tree
Hide file tree
Showing 21 changed files with 53 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .jscs.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
"requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
"requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
"disallowImplicitTypeConversion": ["numeric", "boolean", "binary", "string"],
"disallowImplicitTypeConversion": ["numeric", "binary", "string"],
"disallowKeywords": ["with", "eval"],
"disallowMultipleLineBreaks": true,
"validateLineBreaks": "LF",
Expand Down
16 changes: 8 additions & 8 deletions lib/actions/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ actions.cacheRoot = function cacheRoot() {
};

// Copy helper for two versions of copy action
function prepCopy(source, destination, process) {
actions._prepCopy = function _prepCopy(source, destination, process) {
var body;
destination = destination || source;

Expand Down Expand Up @@ -62,7 +62,7 @@ function prepCopy(source, destination, process) {
destination: destination,
source: source
};
}
};

/**
* Make some of the file API aware of our source/destination root paths.
Expand All @@ -76,7 +76,7 @@ function prepCopy(source, destination, process) {

actions.copy = function copy(source, destination, process) {

var file = prepCopy.call(this, source, destination, process);
var file = this._prepCopy(source, destination, process);

try {
file.body = this.engine(file.body, this);
Expand Down Expand Up @@ -132,7 +132,7 @@ actions.copy = function copy(source, destination, process) {

actions.bulkCopy = function bulkCopy(source, destination, process) {

var file = prepCopy.call(this, source, destination, process);
var file = this._prepCopy(source, destination, process);

mkdirp.sync(path.dirname(file.destination));
fs.writeFileSync(file.destination, file.body);
Expand Down Expand Up @@ -301,7 +301,7 @@ actions.engine = function engine(body, data) {
};

// Shared directory method
function _directory(source, destination, process, bulk) {
actions._directory = function _directory(source, destination, process, bulk) {
// Only add sourceRoot if the path is not absolute
var root = this.isPathAbsolute(source) ? source : path.join(this.sourceRoot(), source);
var files = this.expandFiles('**', { dot: true, cwd: root });
Expand All @@ -325,7 +325,7 @@ function _directory(source, destination, process, bulk) {
}

return this;
}
};

/**
* Copies recursively the files from source directory to root directory.
Expand All @@ -336,7 +336,7 @@ function _directory(source, destination, process, bulk) {
*/

actions.directory = function directory(source, destination, process) {
return _directory.call(this, source, destination, process);
return this._directory(source, destination, process);
};

/**
Expand All @@ -360,7 +360,7 @@ actions.bulkDirectory = function directory(source, destination, process) {
return config.callback();
}

_directory.call(this, source, destination, process, true);
this._directory(source, destination, process, true);
config.callback();
});
return this;
Expand Down
1 change: 1 addition & 0 deletions lib/actions/fetch.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
var fs = require('fs');
var path = require('path');
var request = require('request');
Expand Down
1 change: 1 addition & 0 deletions lib/actions/file.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
var fs = require('fs');
var path = require('path');
var glob = require('glob');
Expand Down
1 change: 1 addition & 0 deletions lib/actions/install.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
var _ = require('lodash');
var dargs = require('dargs');
var async = require('async');
Expand Down
1 change: 1 addition & 0 deletions lib/actions/invoke.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
var path = require('path');

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/actions/spawn_command.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
var _ = require('lodash');
var spawn = require('child_process').spawn;
var win32 = process.platform === 'win32';
Expand All @@ -16,4 +17,3 @@ module.exports = function spawnCommand(command, args, opt) {

return spawn(winCommand, winArgs, _.defaults({ stdio: 'inherit' }, opt));
};

1 change: 1 addition & 0 deletions lib/actions/string.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
var _ = require('lodash');
_.str = require('underscore.string');

Expand Down
1 change: 1 addition & 0 deletions lib/actions/user.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
var shell = require('shelljs');
var _ = require('lodash');

Expand Down
7 changes: 5 additions & 2 deletions lib/actions/wiring.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
var util = require('util');
var fs = require('fs');
var path = require('path');
Expand Down Expand Up @@ -108,7 +109,8 @@ wiring.prependToFile = function prependToFile(path, tagName, content) {
*/

wiring.generateBlock = function generateBlock(blockType, optimizedPath, filesBlock, searchPath) {
var blockStart, blockEnd;
var blockStart;
var blockEnd;
var blockSearchPath = '';

if (searchPath !== undefined) {
Expand Down Expand Up @@ -137,7 +139,8 @@ wiring.generateBlock = function generateBlock(blockType, optimizedPath, filesBlo
*/

wiring.appendFiles = function appendFiles(htmlOrOptions, fileType, optimizedPath, sourceFileList, attrs, searchPath) {
var blocks, updatedContent;
var blocks;
var updatedContent;
var html = htmlOrOptions;
var files = '';

Expand Down
4 changes: 0 additions & 4 deletions lib/env/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ var diff = require('diff');
var chalk = require('chalk');
var logger = require('../util/log');


/**
* `TerminalAdapter` is the default implementation of `Adapter`, an abstraction
* layer that defines the I/O interactions.
Expand All @@ -14,7 +13,6 @@ var logger = require('../util/log');
*/
var TerminalAdapter = module.exports = function TerminalAdapter() {};


TerminalAdapter.prototype._colorDiffAdded = chalk.black.bgGreen;
TerminalAdapter.prototype._colorDiffRemoved = chalk.bgRed;
TerminalAdapter.prototype._colorLines = function colorLines(name, str) {
Expand Down Expand Up @@ -69,5 +67,3 @@ TerminalAdapter.prototype.diff = function _diff(actual, expected) {
};

TerminalAdapter.prototype.log = logger();


17 changes: 8 additions & 9 deletions lib/env/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
var fs = require('fs');
var util = require('util');
var path = require('path');
Expand Down Expand Up @@ -93,7 +94,7 @@ Environment.prototype.appendPath = function appendPath(filepath) {
* Appends the defaults node modules paths to the Environment load paths.
*/

Environment.prototype.appendDefaultPaths = function() {
Environment.prototype.appendDefaultPaths = function () {
this.appendPath(process.cwd());

// We tried using NPM to get the global modules path, but it haven't work out
Expand Down Expand Up @@ -182,7 +183,7 @@ Environment.prototype.register = function register(name, namespace) {
}

var modulePath = this.resolveModulePath(name);
namespace || (namespace = this.namespace(modulePath));
namespace = namespace || this.namespace(modulePath);

if (!namespace) {
return this.error(new Error('Unable to determine namespace.'));
Expand Down Expand Up @@ -248,13 +249,11 @@ Environment.prototype.getGeneratorsMeta = function getGeneratorsMeta() {

Environment.prototype.get = function get(namespace) {
// Stop the recursive search if nothing is left
if (!namespace) {
return;
}
if (!namespace) return;

return this.store.get(namespace)
|| this.store.get(this.alias(namespace))
|| this.get(namespace.split(':').slice(0, -1).join(':'));
return this.store.get(namespace) ||
this.store.get(this.alias(namespace)) ||
this.get(namespace.split(':').slice(0, -1).join(':'));
};

/**
Expand Down Expand Up @@ -419,7 +418,7 @@ Environment.prototype.namespace = function namespace(filepath) {

Environment.prototype.resolveModulePath = function resolveModulePath(moduleId) {
if (moduleId[0] === '.') {
moduleId = path.resolve(moduleId)
moduleId = path.resolve(moduleId);
}

if (moduleId[0] === '~') {
Expand Down
1 change: 1 addition & 0 deletions lib/env/resolver.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
var path = require('path');
var fs = require('fs');
var _ = require('lodash');
Expand Down
3 changes: 2 additions & 1 deletion lib/env/store.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
var util = require('util');
var _ = require('lodash');
var Base = require('../base');
Expand Down Expand Up @@ -45,7 +46,7 @@ Store.prototype._storeAsPath = function _storeAsPath (namespace, path) {

Store.prototype._storeAsModule = function _storeAsModule (namespace, Generator) {
this._meta[namespace] = {
resolved: "unknown",
resolved: 'unknown',
namespace: namespace
};
this._generators[namespace] = Generator;
Expand Down
15 changes: 8 additions & 7 deletions lib/test/helpers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
var fs = require('fs');
var path = require('path');
var rimraf = require('rimraf');
Expand Down Expand Up @@ -148,14 +149,14 @@ helpers.assertTextEqual = function (value, expected) {
};

/**
* Assert an Object implement and interface
* @param {Object} obj subject implementing the façade
* @param {Object|Array} interface a façace, hash or array of keys to be implemented
* Assert an Object implement an interface
* @param {Object} obj - subject implementing the façade
* @param {Object|Array} methods - a façace, hash or array of keys to be implemented
*/

helpers.assertImplement = function(obj, interface) {
var methods = _.isArray(interface) ? interface : Object.keys(interface);
var pass = methods.reduce(function(rest, method) {
helpers.assertImplement = function (obj, methods) {
methods = _.isArray(methods) ? methods : Object.keys(methods);
var pass = methods.reduce(function (rest, method) {
if (obj[method] != null) return true;
return rest;
}, false);
Expand Down Expand Up @@ -235,7 +236,7 @@ helpers.createGenerator = function (name, dependencies, args, options) {
}
});

var generator = env.create(name, {arguments: args, options: options});
var generator = env.create(name, { arguments: args, options: options });

generator.on('start', env.emit.bind(this, 'generators:start'));
generator.on('start', env.emit.bind(this, name + ':start'));
Expand Down
1 change: 1 addition & 0 deletions lib/util/common.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
var chalk = require('chalk');

module.exports.yeoman =
Expand Down
3 changes: 0 additions & 3 deletions lib/util/conflicter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ var Conflicter = module.exports = function Conflicter(adapter) {

util.inherits(Conflicter, events.EventEmitter);


Conflicter.prototype.add = function add(conflict) {
if (typeof conflict === 'string') {
conflict = {
Expand Down Expand Up @@ -138,7 +137,6 @@ Conflicter.prototype._ask = function (filepath, content, cb) {
});
};


Conflicter.prototype.collision = function collision(filepath, content, cb) {
var rfilepath = path.relative(process.cwd(), path.resolve(filepath));
if (!fs.existsSync(filepath)) {
Expand Down Expand Up @@ -175,7 +173,6 @@ Conflicter.prototype.collision = function collision(filepath, content, cb) {
this._ask(filepath, content, cb);
};


// below is borrowed code from visionmedia's excellent mocha (and its reporter)
Conflicter.prototype.diff = function _diff(actual, expected) {
return this.adapter.diff(actual, expected);
Expand Down
3 changes: 1 addition & 2 deletions lib/util/engines.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
var _ = require('lodash');

// TODO(mklabs):
Expand All @@ -7,10 +8,8 @@ var _ = require('lodash');
// template)
// - put in multiple files, possibly other packages.

// engines
var engines = module.exports;


// Underscore
// ----------

Expand Down
17 changes: 9 additions & 8 deletions lib/util/log.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
var util = require('util');
var events = require('events');
var _ = require('lodash');
Expand All @@ -10,13 +11,13 @@ var padding = ' ';

// color -> status mappings
var colors = {
skip : 'yellow',
force : 'yellow',
create : 'green',
invoke : 'bold',
conflict : 'red',
identical : 'cyan',
info : 'gray'
skip: 'yellow',
force: 'yellow',
create: 'green',
invoke: 'bold',
conflict: 'red',
identical: 'cyan',
info: 'gray'
};

function pad(status) {
Expand Down Expand Up @@ -158,7 +159,7 @@ module.exports = function logger() {
log.table = function (opts) {
var tableData = [];

opts = Array.isArray(opts) ? { rows: opts } : opts;
opts = Array.isArray(opts) ? { rows: opts }: opts;
opts.rows = opts.rows || [];

opts.rows.forEach(function (row) {
Expand Down
Empty file removed lib/util/misc.js
Empty file.
4 changes: 2 additions & 2 deletions lib/util/storage.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';
var fs = require('fs');
var path = require('path');
var EventEmitter = require('events').EventEmitter;
var _ = require('lodash');
var util = require('util');


/**
* Storage instances handle a json file where Generator authors can store data.
* @param {String} name The name of the new storage (this is a namespace)
Expand Down Expand Up @@ -59,7 +59,7 @@ Storage.prototype.loadConfig = function () {
* @return {null}
*/

Storage.prototype.save = function() {};
Storage.prototype.save = function () {};

/**
* Force save (synchronously write the store to disk).
Expand Down

0 comments on commit 34441c2

Please sign in to comment.