diff --git a/lib/index.js b/lib/index.js index 39bb0a9..f6d766d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -27,7 +27,6 @@ internals.prepareOptions = function(options){ internals.resolveIncludes = function(options){ - function hasDependency(dependencyName, type){ return options[type].some(function(entry){ return dependencyName && dependencyName === entry.name; @@ -60,7 +59,7 @@ internals.resolveIncludes = function(options){ } if (mod.preprocessors){ entry.preprocessors = mod.preprocessors; - entry.dependencies.forEach(function(dependencyName){ + entry.preprocessors.forEach(function(dependencyName){ addDependency(dependencyName, 'preprocess'); }); } @@ -78,6 +77,8 @@ internals.resolveIncludes = function(options){ // todo: dependencies relative to same path? ./ options.validate.forEach(readDependencies); options.preprocess.forEach(readDependencies); + + console.log('options.preprocess', options.preprocess); }; internals.run = function (options, callback) { if (!callback){ diff --git a/lib/rule/preprocess/jquery.js b/lib/rule/preprocess/jquery.js index d151bc8..b563c4b 100644 --- a/lib/rule/preprocess/jquery.js +++ b/lib/rule/preprocess/jquery.js @@ -1,6 +1,6 @@ var tool = require('../lib/getLatestJquery.js'); -function getLastest(harvested, output, next/*, options, config*/) { +function getLastest(harvested, output, next) { var collected = harvested.jquery.version; output('versionObj', tool.createVersionObj(collected)); @@ -13,7 +13,7 @@ function getLastest(harvested, output, next/*, options, config*/) { module.exports = { dependencies: ['jquery'], preprocess: function (harvested, output, next) { - if (harvested.jquery.version) { + if (harvested.jquery && harvested.jquery.version) { getLastest.apply(this, Array.prototype.slice.call(arguments)); } else { next(); diff --git a/lib/rule/validate/jquery.js b/lib/rule/validate/jquery.js index a1feb82..182e21c 100644 --- a/lib/rule/validate/jquery.js +++ b/lib/rule/validate/jquery.js @@ -2,8 +2,8 @@ var internals = {}; internals.validateLatest = function (harvested, report, next /*, globalOptions*/ ) { var jq = harvested.jquery; - var key = jq.versionObj.sortKey; - var isOk = jq.versions.some(function (o) { + var key = jq.versionObj && jq.versionObj.sortKey; + var isOk = jq.versions && jq.versions.some(function (o) { return key === o.sortKey; }); @@ -42,8 +42,8 @@ internals.validate = function (harvested, report, next) { }; module.exports = { - dependencies: ['jquery'], - preprocessors: ['jquery'], - validateLatest: internals.validateLatest, - validate: internals.validate + 'dependencies': ['jquery'], + 'preprocessors': ['jquery'], + 'validateLatest': internals.validateLatest, + 'validate': internals.validate };