Code style consistency

Some very minor changes to improve code style consistency.
This commit is contained in:
Nicolas Gallagher
2013-05-02 19:51:51 -07:00
parent 20ca17fcac
commit de0eca7890
20 changed files with 195 additions and 184 deletions

View File

@@ -2,6 +2,7 @@ var path = require('path');
var fs = require('fs');
var mout = require('mout');
var mkdirp = require('mkdirp');
var rc = require('rc');
// Guess some needed properties based on the user OS
var temp = process.env.TMPDIR
@@ -28,7 +29,7 @@ var proxy = process.env.HTTPS_PROXY
// Read global bower config
var config;
try {
config = require('rc')('bower', {
config = rc('bower', {
directory: 'bower_components',
shorthandResolver: 'git://github.com/{{owner}}/{{package}}.git',
proxy: proxy,

View File

@@ -39,9 +39,9 @@ Resolver.prototype.getTempDir = function () {
};
Resolver.prototype.hasNew = function (canonicalPkg) {
var that = this,
promise,
metaFile;
var that = this;
var promise;
var metaFile;
// If already working, error out
if (this._working) {
@@ -210,4 +210,4 @@ Resolver.prototype._savePkgMeta = function (meta) {
}.bind(this));
};
module.exports = Resolver;
module.exports = Resolver;

View File

@@ -17,9 +17,9 @@ util.inherits(Worker, events.EventEmitter);
// -----------------
Worker.prototype.enqueue = function (func, type) {
var deferred = Q.defer(),
types,
entry;
var deferred = Q.defer();
var types;
var entry;
type = type || '';
types = Array.isArray(type) ? type : [type];
@@ -61,9 +61,9 @@ Worker.prototype.abort = function () {
// -----------------
Worker.prototype._processQueue = function (type) {
var queue = this._queue[type],
length = queue ? queue.length : 0,
x;
var queue = this._queue[type];
var length = queue ? queue.length : 0;
var x;
for (x = 0; x < length; ++x) {
if (this._processEntry(queue[x])) {
@@ -73,8 +73,8 @@ Worker.prototype._processQueue = function (type) {
};
Worker.prototype._processEntry = function (entry) {
var allFree = entry.types.every(this._hasSlot, this),
promise;
var allFree = entry.types.every(this._hasSlot, this);
var promise;
// If there is a free slot for every tag
if (allFree) {
@@ -148,4 +148,4 @@ Worker.prototype._freeSlot = function (type) {
}
};
module.exports = Worker;
module.exports = Worker;

View File

@@ -10,9 +10,9 @@ var config = require('../config');
var createError = require('../util/createError');
function createResolver(endpoint, options) {
var split = endpoint.split('#'),
source,
target;
var split = endpoint.split('#');
var source;
var target;
// TODO: extract name from the endpoint and set it up in the options.name
// not sure about the @ being used to specify it because it may conflict
@@ -83,4 +83,4 @@ function createResolver(endpoint, options) {
});
}
module.exports = createResolver;
module.exports = createResolver;

View File

@@ -41,9 +41,9 @@ FsResolver.prototype._resolve = function () {
FsResolver.prototype._copy = function (meta) {
return Q.nfcall(fs.stat, this._source)
.then(function (stat) {
var dstFile,
copyOpts,
promise;
var dstFile;
var copyOpts;
var promise;
this._sourceStat = stat;
@@ -80,9 +80,9 @@ FsResolver.prototype._extract = function (file) {
FsResolver.prototype._rename = function () {
return Q.nfcall(fs.readdir, this._tempDir)
.then(function (files) {
var file,
oldPath,
newPath;
var file;
var oldPath;
var newPath;
// Remove any OS specific files from the files array
// before checking its length
@@ -108,4 +108,4 @@ FsResolver.prototype._savePkgMeta = function (meta) {
return Resolver.prototype._savePkgMeta.call(this, meta);
};
module.exports = FsResolver;
module.exports = FsResolver;

View File

@@ -23,8 +23,8 @@ mout.object.mixIn(GitRemoteResolver, GitResolver);
// -----------------
GitRemoteResolver.prototype._checkout = function () {
var branch,
resolution = this._resolution;
var branch;
var resolution = this._resolution;
// If resolution is a commit, we need to clone the entire repo and check it out
// Because a commit is not a named ref, there's no better solution

View File

@@ -54,6 +54,7 @@ GitResolver.prototype._resolve = function () {
GitResolver.prototype._checkout = function () {
throw new Error('_checkout not implemented');
};
GitResolver.fetchRefs = function (source) {
throw new Error('fetchRefs not implemented');
};
@@ -61,8 +62,8 @@ GitResolver.fetchRefs = function (source) {
// -----------------
GitResolver.prototype._findResolution = function (target) {
var self = this.constructor,
err;
var self = this.constructor;
var err;
target = target || this._target;
@@ -195,9 +196,9 @@ GitResolver.fetchVersions = function (source) {
return this.fetchTags(source)
.then(function (tags) {
var versions = [],
tag,
version;
var versions = [];
var tag;
var version;
// For each tag
for (tag in tags) {
@@ -228,8 +229,8 @@ GitResolver.fetchTags = function (source) {
// For each line in the refs, match only the tags
refs.forEach(function (line) {
var match = line.match(/^([a-f0-9]{40})\s+refs\/tags\/(\S+)/),
tag;
var match = line.match(/^([a-f0-9]{40})\s+refs\/tags\/(\S+)/);
var tag;
if (match) {
tag = match[2];

View File

@@ -33,8 +33,8 @@ util.inherits(UrlResolver, Resolver);
// -----------------
UrlResolver.prototype._hasNew = function (pkgMeta) {
var oldCacheHeaders = pkgMeta._cacheHeaders || {},
reqHeaders = {};
var oldCacheHeaders = pkgMeta._cacheHeaders || {};
var reqHeaders = {};
// If the previous cache headers contain an ETag,
// send the "If-None-Match" header with it
@@ -88,13 +88,13 @@ UrlResolver.prototype._resolve = function () {
// -----------------
UrlResolver.prototype._download = function () {
var file = path.join(this._tempDir, this._name),
deferred = Q.defer(),
req,
res,
writer,
finish,
that = this;
var file = path.join(this._tempDir, this._name);
var deferred = Q.defer();
var req;
var res;
var writer;
var finish;
var that = this;
finish = function (err) {
// Ensure that all listeners are removed
@@ -132,9 +132,9 @@ UrlResolver.prototype._download = function () {
};
UrlResolver.prototype._parseHeaders = function (file, response) {
var disposition,
newFile,
match;
var disposition;
var newFile;
var match;
// Check if we got a Content-Disposition header
disposition = response.headers['content-disposition'];
@@ -187,9 +187,9 @@ UrlResolver.prototype._extract = function (file, response) {
UrlResolver.prototype._rename = function () {
return Q.nfcall(fs.readdir, this._tempDir)
.then(function (files) {
var file,
oldPath,
newPath;
var file;
var oldPath;
var newPath;
// Remove any OS specific files from the files array
// before checking its length
@@ -243,4 +243,4 @@ UrlResolver._cacheHeaders = [
'Content-Disposition'
];
module.exports = UrlResolver;
module.exports = UrlResolver;

View File

@@ -7,10 +7,10 @@ var createError = require('./createError');
// Returns a promise that gets fulfilled if the command succeeds
// or rejected if it fails
function cmd(command, args, options) {
var process,
stderr = '',
stdout = '',
deferred = Q.defer();
var process;
var stderr = '';
var stdout = '';
var deferred = Q.defer();
process = cp.spawn(command, args, options);
process.stdout.on('data', function (data) { stdout += data.toString(); });
@@ -19,8 +19,8 @@ function cmd(command, args, options) {
// Listen to the close event instead of exit
// They are similar but close ensures that streams are flushed
process.on('close', function (code) {
var fullCommand,
error;
var fullCommand;
var error;
if (code) {
// Generate the full command to be presented in the error message
@@ -46,4 +46,4 @@ function cmd(command, args, options) {
return deferred.promise;
}
module.exports = cmd;
module.exports = cmd;

View File

@@ -4,9 +4,9 @@ var fs = require('fs');
var Q = require('q');
function copy(reader, writer) {
var deferred = Q.defer(),
ignore,
finish;
var deferred = Q.defer();
var ignore;
var finish;
finish = function (err) {
// Ensure that all listeners are removed
@@ -117,4 +117,4 @@ function copyDir(src, dst, opts) {
}
module.exports.copyDir = copyDir;
module.exports.copyFile = copyFile;
module.exports.copyFile = copyFile;

View File

@@ -11,8 +11,8 @@ var osJunk = require('./osJunk');
// to avoid issue #314
zlib.Z_DEFAULT_CHUNK = 1024 * 8;
var extractors,
extractorTypes;
var extractors;
var extractorTypes;
extractors = {
'.zip': extractZip,
@@ -25,6 +25,7 @@ extractors = {
'application/x-tgz': extractTarGz,
'application/x-gzip': extractGz
};
extractorTypes = Object.keys(extractors);
function extractZip(archive, dest) {
@@ -115,8 +116,8 @@ function moveSingleDirContents(dir) {
var promises;
promises = files.map(function (file) {
var src = path.join(dir, file),
dest = path.join(destDir, file);
var src = path.join(dir, file);
var dest = path.join(destDir, file);
return Q.nfcall(fs.rename, src, dest);
});
@@ -138,8 +139,8 @@ function canExtract(target) {
// - keepArchive: true to keep the archive afterwards (defaults to false)
// - keepStructure: true to keep the extracted structure unchanged (defaults to false)
function extract(src, dest, opts) {
var extractor,
promise;
var extractor;
var promise;
opts = opts || {};
extractor = getExtractor(opts.mimeType || src);
@@ -178,4 +179,4 @@ function extract(src, dest, opts) {
}
module.exports = extract;
module.exports.canExtract = canExtract;
module.exports.canExtract = canExtract;