Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wiredep

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wiredep - npm Package Compare versions

Comparing version 0.1.2 to 0.1.4

74

lib/detect-dependencies.js

@@ -14,4 +14,6 @@ /*

var _ = require('lodash');
var helpers = require('./helpers');
var prop = helpers.prop;
var equals = helpers.equals;
/**

@@ -48,23 +50,27 @@ * Find the component's JSON configuration file.

* @param {componentConfigFile} the component's config file
* @return {string} the path to the component's primary file
* @return {array} the array of paths to the component's primary file(s)
*/
var findMainFile = function (config, component, componentConfigFile) {
var filePath;
var findMainFiles = function (config, component, componentConfigFile) {
var filePaths = [];
var file;
if (_.isString(componentConfigFile.main)) {
// start by looking for what every component should have: config.main
filePath = componentConfigFile.main;
filePaths = [componentConfigFile.main];
} else if (_.isArray(componentConfigFile.main)) {
// in case config.main is an array, grab the first one (grab all instead?)
filePath = componentConfigFile.main[0];
filePaths = componentConfigFile.main;
} else if (_.isArray(componentConfigFile.scripts)) {
// still haven't found it. is it stored in config.scripts, then?
filePath = componentConfigFile.scripts[0];
filePaths = componentConfigFile.scripts;
} else {
file = path.join(config.get('directory'), component, componentConfigFile.name + '.js');
if (fs.existsSync(file)) {
filePaths = [componentConfigFile.name + '.js'];
}
}
if (_.isString(filePath)) {
filePath = path.join(config.get('directory'), component, filePath);
}
return filePath;
return filePaths.map(function (file) {
return path.join(config.get('directory'), component, file);
});
};

@@ -97,12 +103,11 @@

var componentConfigFile = findComponentConfigFile(config, component);
var warnings = config.get('warnings');
dep.main = findMainFile(config, component, componentConfigFile);
dep.type = path.extname(dep.main);
dep.main = findMainFiles(config, component, componentConfigFile);
dep.type = path.extname(dep.main[0]);
dep.name = componentConfigFile.name;
dep.dependents += 1;
if (!_.isString(dep.main)) {
if (dep.main.length === 0) {
// can't find the main file. this config file is useless!
var warnings = config.get('warnings');
warnings.push(component + ' was not injected in your file.');

@@ -141,3 +146,3 @@ warnings.push(

return dependency === lastDependency.name;
}).length ? 1 : -1;
}).length ? 1 : 0;
};

@@ -154,13 +159,26 @@

var prioritizeDependencies = function (config, fileType) {
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;
var eliteDependencies = ['jquery', 'zepto', 'modernizr'];
var eliteDependenciesCaught = [];
var dependencies =
_.toArray(config.get('global-dependencies').get()).
filter(equals('type', fileType)).
reduce(function (grouped, dependency) {
return grouped.push(dependency) && grouped.sort(dependencyComparator);
}, []).
filter(function (dependency) {
if (_.contains(eliteDependencies, dependency.name)) {
eliteDependenciesCaught.push(dependency.main);
} else {
return true;
}
}).
map(prop('main'));
eliteDependenciesCaught.
forEach(function (dependency) {
dependencies.unshift(dependency);
});
return _.flatten(dependencies);
};

@@ -167,0 +185,0 @@

@@ -56,2 +56,29 @@ /*

/**
* Return just a property from an object.
*
* @param {string} prop the key of the object to return
* @return {function}
*/
module.exports.prop = function (prop) {
return function (item) {
return item[prop];
};
};
/**
* Check if a prop is equal to the comparison argument.
*
* @param {string} prop the key of the object that will be compared
* @param {*} comparison the object that will be compared against
* @return {function}
*/
module.exports.equals = function (prop, comparison) {
return function (item) {
return item[prop] === comparison;
};
};
/**
* Quick litle buddy that pads and throws some warnings when something goes :(

@@ -58,0 +85,0 @@ *

@@ -34,2 +34,4 @@ /*

spacing = '\n' + spacing.replace(/\n/g, '');
if (dependencies.length) {

@@ -36,0 +38,0 @@ globalDependenciesSorted[blockType || 'js'].forEach(function (path) {

{
"name": "wiredep",
"version": "0.1.2",
"version": "0.1.4",
"description": "Wire dependencies to your source code.",

@@ -11,2 +11,10 @@ "homepage": "https://github.com/stephenplusplus/wiredep",

},
"keywords": [
"bower",
"package",
"management",
"inject",
"script",
"dependencies"
],
"main": "bin/wiredep",

@@ -13,0 +21,0 @@ "files": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc