Skip to content
Permalink
Browse files

use Function#bind when it's appropriate, use single quotes

  • Loading branch information
fb55 committed Sep 8, 2012
1 parent a7c35d1 commit d9c45ebb3d4b5558d44941bfb3f19fac0798d668
Showing with 13 additions and 17 deletions.
  1. +13 −17 lib/require-analyzer.js
@@ -57,11 +57,7 @@ analyzer.analyze = function (options, callback) {
// for streaming results.
//
['search', 'reduce'].forEach(function (ev) {
npmEmitter.on(ev, function () {
var args = Array.prototype.slice.call(arguments);
args.unshift(ev);
emitter.emit.apply(emitter, args);
});
npmEmitter.on(ev, emitter.emit.bind(emitter, ev));
});
});

@@ -96,12 +92,12 @@ analyzer.path = function(options, callback){
analyzer.dir(options, callback);
}
else if (stats.isFile()) {
if("fileFilter" in options && !options.fileFilter(options.target)) return;
if('fileFilter' in options && !options.fileFilter(options.target)) return;
analyzer.file(options, callback);
}
else {
err = new Error(options.target + ' is not a file or a directory.');
err.code = "UNSUPPORTED_TYPE";
err.code = 'UNSUPPORTED_TYPE';
callback(err);
}
});
@@ -237,9 +233,9 @@ analyzer.dir = function (options, callback) {
//
files.forEach(function(file){
//
// skip all files from "node_modules" directories
// skip all files from 'node_modules' directories
//
if(file === "node_modules") return;
if(file === 'node_modules') return;

//
// call analyzer.path and currate all dependencies
@@ -249,7 +245,7 @@ analyzer.dir = function (options, callback) {
target: path.join(target, file),
fileFilter: filterFiles
}, function(err, deps){
if(err && err.code !== "UNSUPPORTED_TYPE"){
if(err && err.code !== 'UNSUPPORTED_TYPE'){
//
// skip symlinks & friends
// but forward real errors
@@ -337,7 +333,7 @@ analyzer.package = function (options, callback) {
});
}

var scripts = 'scripts' in options ? options.scripts : ["test","prestart"];
var scripts = 'scripts' in options ? options.scripts : ['test','prestart'];

scripts = scripts.map(function (item) {
return pkg.scripts && pkg.scripts[item];
@@ -405,8 +401,8 @@ analyzer.package = function (options, callback) {
}

// add logic to default to app.js or server.js for main if main is not present.
if ( !("main" in pkg) || pkg.main === '') {
var files = ["app.js", "server.js", "index.js"];
if ( !('main' in pkg) || pkg.main === '') {
var files = ['app.js', 'server.js', 'index.js'];
setMain(files, pkg, newoptions, setTarget);
}
else {
@@ -478,12 +474,12 @@ function spawnWorker (options, callback) {

deps.send(options.target);

deps.on("message", function(data){
deps.on('message', function(data){
switch(data.type){
case "load":
case 'load':
packages[data.msg] = true;
break;
case "error":
case 'error':
errs.push(data.msg);
}
});
@@ -600,7 +596,7 @@ analyzer.merge = function (target) {
var objs = Array.prototype.slice.call(arguments, 1);
objs.forEach(function (o) {
Object.keys(o).forEach(function (attr) {
if ( !("get" in Object.getOwnPropertyDescriptor(o, attr)) ) {
if ( !('get' in Object.getOwnPropertyDescriptor(o, attr)) ) {
target[attr] = o[attr];
}
});

0 comments on commit d9c45eb

Please sign in to comment.
You can’t perform that action at this time.