module-deps
Advanced tools
Comparing version 0.10.3 to 0.11.0
45
index.js
@@ -9,3 +9,3 @@ var fs = require('fs'); | ||
var through = require('through'); | ||
var concatStream = require('concat-stream'); | ||
var concat = require('concat-stream'); | ||
@@ -18,3 +18,3 @@ module.exports = function (mains, opts) { | ||
mains = mains.map(function (file) { | ||
return path.resolve(file); | ||
return typeof file === 'object' ? file : path.resolve(file); | ||
}); | ||
@@ -44,2 +44,20 @@ | ||
if (id && typeof id === 'object' && typeof id.pipe === 'function') { | ||
return id.pipe(concat(function (src) { | ||
var n = Math.floor(Math.pow(16,8) * Math.random()).toString(16); | ||
var basedir = opts.basedir || process.cwd(); | ||
var file = path.join(basedir, 'fake_' + n + '.js'); | ||
var pkgfile = path.join(basedir, 'package.json'); | ||
fs.readFile(pkgfile, function (err, pkgsrc) { | ||
var pkg = {}; | ||
if (!err) { | ||
try { pkg = JSON.parse(pkgsrc) } | ||
catch (e) {}; | ||
} | ||
var trx = getTransform(pkg); | ||
applyTransforms(file, trx, src, pkg); | ||
}); | ||
})); | ||
} | ||
var c = opts.cache && opts.cache[parent.id]; | ||
@@ -69,10 +87,3 @@ var resolver = c && typeof c === 'object' | ||
var trx = []; | ||
if (opts.transformKey) { | ||
var n = pkg; | ||
opts.transformKey.forEach(function (key) { | ||
if (n && typeof n === 'object') n = n[key]; | ||
}); | ||
trx = [].concat(n).filter(Boolean); | ||
} | ||
var trx = getTransform(pkg); | ||
@@ -89,2 +100,14 @@ if (cache && cache[file]) { | ||
function getTransform (pkg) { | ||
var trx = []; | ||
if (opts.transformKey) { | ||
var n = pkg; | ||
opts.transformKey.forEach(function (key) { | ||
if (n && typeof n === 'object') n = n[key]; | ||
}); | ||
trx = [].concat(n).filter(Boolean); | ||
} | ||
return trx; | ||
} | ||
function applyTransforms (file, trx, src, pkg) { | ||
@@ -104,3 +127,3 @@ var isTopLevel = mains.some(function (main) { | ||
s.on('error', output.emit.bind(output, 'error')); | ||
s.pipe(concatStream(function (data) { | ||
s.pipe(concat(function (data) { | ||
src = data; | ||
@@ -107,0 +130,0 @@ ap(trs.slice(1)); |
{ | ||
"name": "module-deps", | ||
"version": "0.10.3", | ||
"version": "0.11.0", | ||
"description": "walk the dependency graph to generate json output that can be fed into browser-pack", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
26398
63
588
140
13