New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

require-package

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

require-package - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

36

lib/require-package.js

@@ -22,3 +22,4 @@ var path = require('path');

package: 'package',
key: 'vendor'
key: 'vendor',
packageKey: 'packages'
}, (config || {}));

@@ -29,7 +30,14 @@

try {
var vendor = require(packageFilename)[config.key];
var package = require(packageFilename);
} catch (e) {
return invalid('Invalid path for package.json: '+packageFilename);
if (e.code=='MODULE_NOT_FOUND') {
return invalid('Invalid path for package.json: '+packageFilename);
} else {
throw e;
}
}
var vendor = package[config.key] || {};
var packages = package[config.packageKey] || [];
return {

@@ -51,3 +59,3 @@ from: from,

config: function(vendorDir, base) {
var conf = base || {};
var conf = _.clone(base || {});
conf.paths = _.reduce(vendor, function(memo,info,key) {

@@ -61,3 +69,23 @@ memo[key] = path.join(vendorDir,(info.file || key));

}, (conf.shim || {}));
if (packages) {
conf.packages = (conf.packages || []).concat(_.map(packages, function(p) {
if (_.isString(p)) {
return {name: p, location: './'+p, main: 'index'};
} else {
return _.extend({main: 'index'}, p);
}
}));
};
return conf;
},
// Modify config to optimize for package
optimize: function(name, config) {
_.each(config.paths || {}, function(path, key) {
config.paths[key] = 'empty:';
});
_.each(config.packages || [], function(pkg) {
if (pkg.name !== name) config.paths[pkg.name] = 'empty:';
});
return config;
}

@@ -64,0 +92,0 @@ };

2

package.json
{
"name": "require-package",
"version": "0.0.2",
"version": "0.1.0",
"description": "Generate requirejs configuration from package.json values",

@@ -5,0 +5,0 @@ "main": "lib/require-package.js",

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