Skip to content

Commit

Permalink
type + better object check
Browse files Browse the repository at this point in the history
  • Loading branch information
sveisvei committed Mar 31, 2014
1 parent c53f09d commit a20aa06
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
});
}
Expand All @@ -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){
Expand Down
4 changes: 2 additions & 2 deletions lib/rule/preprocess/jquery.js
Original file line number Diff line number Diff line change
@@ -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));

Expand All @@ -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();
Expand Down
12 changes: 6 additions & 6 deletions lib/rule/validate/jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

Expand Down Expand Up @@ -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
};

0 comments on commit a20aa06

Please sign in to comment.