Comparing version 0.1.0 to 0.1.1
@@ -26,3 +26,6 @@ /* | ||
_.each(['.bower.json', 'bower.json', 'component.json', 'package.json'], function (configFile) { | ||
['.bower.json', | ||
'bower.json', | ||
'component.json', | ||
'package.json'].forEach(function (configFile) { | ||
configFile = path.join(config.get('directory'), component, configFile); | ||
@@ -38,2 +41,3 @@ | ||
/** | ||
@@ -73,6 +77,5 @@ * Find the main file the component refers to. It's not always main :( | ||
* @param {object} config the global configuration object | ||
* @param {object} options optional parameters | ||
* @return {function} the iterator function, called on every component | ||
*/ | ||
var gatherInfo = function (config, options) { | ||
var gatherInfo = function (config) { | ||
/** | ||
@@ -87,5 +90,7 @@ * The iterator function, which is called on each component. | ||
var dep = config.get('global-dependencies').get(component) || { | ||
main: '', | ||
type: '', | ||
main: '', | ||
dependencies: {}, | ||
name: '', | ||
dependents: 0, | ||
dependencies: {} | ||
}; | ||
@@ -95,10 +100,6 @@ | ||
if (_.isNumber(dep.dependents)) { | ||
dep.dependents += 1; | ||
} else { | ||
dep.dependents = 1; | ||
} | ||
dep.main = findMainFile(config, component, componentConfigFile); | ||
dep.type = path.extname(dep.main); | ||
dep.name = componentConfigFile.name; | ||
dep.dependents += 1; | ||
@@ -109,7 +110,7 @@ if (!_.isString(dep.main)) { | ||
warnings.push(component + ' was not injected in your HTML.'); | ||
warnings.push(component + ' was not injected in your file.'); | ||
warnings.push( | ||
'Please go take a look in "' | ||
+ path.join(config.get('directory'), component) | ||
+ '" for the file you need, then manually include it in your HTML file.'); | ||
+ '" for the file you need, then manually include it in your file.'); | ||
@@ -120,10 +121,6 @@ config.set('warnings', warnings); | ||
if (options.nestedDependencies && componentConfigFile.dependencies) { | ||
var gatherInfoAgain = gatherInfo(config, { nestedDependencies: false }); | ||
if (componentConfigFile.dependencies) { | ||
dep.dependencies = componentConfigFile.dependencies; | ||
_.each(componentConfigFile.dependencies, function (version, component) { | ||
gatherInfoAgain(version, component); | ||
}); | ||
_.each(componentConfigFile.dependencies, gatherInfo(config)); | ||
} | ||
@@ -137,2 +134,18 @@ | ||
/** | ||
* Compare two dependencies to determine priority. | ||
* | ||
* @param {object} dependency dependency a | ||
* @param {object} lastDependency dependency b | ||
* @return {number} the priority of dependency a in comparison to dependency b | ||
*/ | ||
var dependencyComparator = function (dependency, lastDependency) { | ||
return Object. | ||
keys(dependency.dependencies). | ||
filter(function (dependency) { | ||
return dependency === lastDependency.name; | ||
}).length ? 1 : -1; | ||
}; | ||
/** | ||
* Sort the dependencies in the order we can best determine they're needed. | ||
@@ -145,18 +158,13 @@ * | ||
var prioritizeDependencies = function (config, fileType) { | ||
var globalDependencies = config.get('global-dependencies').get(); | ||
var grouped = _.chain(globalDependencies).filter(function (dep) { | ||
return dep.type === fileType; | ||
}).groupBy('dependents').value(); | ||
var sorted = []; | ||
_.each(grouped, function (dependencies) { | ||
_.chain(dependencies).groupBy(function (dependency) { | ||
return _.size(dependency.dependencies); | ||
}).toArray().value().reverse().forEach(function (dependency) { | ||
_.each(dependency, function (dependency) { | ||
sorted.push(dependency.main); | ||
}); | ||
return _.toArray(config.get('global-dependencies').get()). | ||
filter(function (dep) { | ||
return dep.type === fileType; | ||
}). | ||
reduce(function (grouped, dependency) { | ||
grouped.push(dependency); | ||
return grouped.sort(dependencyComparator); | ||
}, []). | ||
map(function (dependency) { | ||
return dependency.main; | ||
}); | ||
}); | ||
return sorted.reverse(); | ||
}; | ||
@@ -172,4 +180,3 @@ | ||
module.exports = function detect(config) { | ||
_.each(config.get('bower.json').dependencies, gatherInfo(config, | ||
{ nestedDependencies: true })); | ||
_.each(config.get('bower.json').dependencies, gatherInfo(config)); | ||
@@ -176,0 +183,0 @@ config.set('global-dependencies-sorted', { |
@@ -11,3 +11,5 @@ /* | ||
var chalk = require('chalk'); | ||
/** | ||
@@ -66,3 +68,3 @@ * Returns a set/get style internal storage bucket. | ||
+ '\n' | ||
+ '\n http://github.com/stephenplusplus/wiredep'.cyan | ||
+ '\n https://github.com/stephenplusplus/wiredep' | ||
); | ||
@@ -73,18 +75,12 @@ } | ||
var displayedMessages = {}; | ||
messages.forEach(function (message, index) { | ||
if (displayedMessages[message]) { | ||
return; | ||
if (!displayedMessages[message]) { | ||
displayedMessages[message] = true; | ||
if (index % 2 === 0) { | ||
console.log('\n' + chalk.bgMagenta(message)); | ||
} else { | ||
console.log(message); | ||
} | ||
} | ||
displayedMessages[message] = true; | ||
if (index % 2 === 0) { | ||
// a heading. | ||
console.log(message.yellow); | ||
} else { | ||
// the sub-text to the heading. | ||
console.log(message.cyan); | ||
} | ||
}); | ||
}; | ||
}; |
{ | ||
"name": "wiredep", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Wire dependencies to your source code.", | ||
@@ -31,4 +31,5 @@ "homepage": "https://github.com/stephenplusplus/wiredep", | ||
"dependencies": { | ||
"lodash": "~1.3.0" | ||
"lodash": "~1.3.0", | ||
"chalk": "~0.1.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11359
271
2
+ Addedchalk@~0.1.1
+ Addedansi-styles@0.1.2(transitive)
+ Addedchalk@0.1.1(transitive)
+ Addedhas-color@0.1.7(transitive)