Comparing version 2.3.8 to 2.3.9
@@ -72,5 +72,3 @@ var os = require('os'), | ||
var includes = this.options['include']; | ||
(Array.isArray(includes) ? includes : [ includes ]).map(function(filepath) { | ||
this.options['include'].map(function(filepath) { | ||
list.add(filepath); | ||
@@ -77,0 +75,0 @@ }); |
var fs = require('fs'), | ||
path = require('path'), | ||
annotateStructured = require('./annotate-structured.js'), | ||
inferPackageDependencies = require('./infer-package-dependencies.js'); | ||
annotateStructured = require('./annotate-structured.js'); | ||
@@ -49,7 +48,7 @@ // assigns unique ids to packages to disabiguate between packages with the same name | ||
if(exists(list.files, guess)) { | ||
mainFile = path.normalize(data.main); | ||
mainFile = data.main; | ||
} else if(exists(list.files, guess + '.js')) { | ||
mainFile = path.normalize(data.main + '.js'); | ||
mainFile = data.main + '.js'; | ||
} else if(exists(list.files, guess + '.json')) { | ||
mainFile = path.normalize(data.main + '.json'); | ||
mainFile = data.main + '.json'; | ||
} else if(exists(list.files, guess + '/index.js')) { | ||
@@ -76,5 +75,3 @@ mainFile = path.normalize(data.main + '/index.js'); | ||
var packages = [ { | ||
files: [] | ||
} ]; | ||
var packages = [ { files: [], dependenciesById: {} } ]; | ||
@@ -121,4 +118,7 @@ // we cannot auto-detect the basepath (since the base package might consist of multiple | ||
main: mainFile, | ||
files: [ file ] | ||
files: [ file ], | ||
dependenciesById: {} | ||
}; | ||
// add parent dependency | ||
packages[packageIndex].dependenciesById[packageName] = packages[index].uid; | ||
}); | ||
@@ -143,4 +143,7 @@ } | ||
main: mainFile, | ||
files: [] | ||
files: [], | ||
dependenciesById: {} | ||
}; | ||
// add parent dependency | ||
packages[packageIndex].dependenciesById[packageName] = packages[index].uid; | ||
// traverse | ||
@@ -173,5 +176,7 @@ getPackage(root.node_modules[dirname], packageBase, index); | ||
list.packages = packages; | ||
}; | ||
inferPackageDependencies(list, options); | ||
// to override the fs module, which is only used for reading in package.json files | ||
module.exports._setFS = function(newFs) { | ||
fs = newFs; | ||
}; |
@@ -77,5 +77,5 @@ var fs = require('fs'), | ||
this._resolveErrors = []; | ||
return oldExec.apply(this, Array.prototype.slice.apply(arguments)); | ||
oldExec.apply(this, Array.prototype.slice.apply(arguments)); | ||
}; | ||
module.exports = DetectiveList; |
@@ -25,4 +25,2 @@ var fs = require('fs'), | ||
log.debug('Cache:', opts['cache-method'], opts['cache-path'], opts['cache-hash']); | ||
// replace the find function to use node-detective | ||
@@ -39,2 +37,3 @@ this.find(function(filepath, stat, onDone) { | ||
if (!noCache && Array.isArray(result)) { | ||
// console.log('using cached result', filepath, result); | ||
var renames = cache.file(filepath).data(renameKey); | ||
@@ -44,6 +43,3 @@ if(renames && Array.isArray(renames)) { | ||
} | ||
log.debug('Using cached result:', filepath, result); | ||
return onDone(null, result); | ||
} else { | ||
// log.debug('Nothing in cache for:', filepath, resultKey); | ||
} | ||
@@ -53,10 +49,11 @@ | ||
log.info('Parsing:', filepath, result); | ||
// check the cache | ||
deps = cache.file(filepath).data(depKey); | ||
if (noCache || typeof deps === 'undefined') { | ||
// log.debug('Parsing:', filepath); | ||
try { | ||
deps = detective(fs.readFileSync(filepath).toString()); | ||
} catch(e) { | ||
log.error('Parse error: ', filepath, e); | ||
console.log('parse error: ', filepath, e); | ||
cache.file(filepath).data(depKey, []); | ||
@@ -68,3 +65,3 @@ return []; | ||
} else { | ||
log.debug('Using cached deps:', filepath, deps); | ||
// console.log('using cached result', filepath, deps); | ||
} | ||
@@ -77,3 +74,2 @@ | ||
cache.file(filepath).data(resultKey, []); | ||
log.debug('Result:', filepath, []); | ||
return onDone(null, []); | ||
@@ -83,4 +79,3 @@ } | ||
var expected = deps.length, | ||
complete = 0, | ||
hasErrors = false; | ||
complete = 0; | ||
@@ -96,8 +91,8 @@ result = []; | ||
complete++; | ||
if (err) { | ||
hasErrors = true; | ||
log.error('Resolve error:', err, dep, filepath, result); | ||
if(err) { | ||
// console.log('resolve error: ', err, dep, filepath, result); | ||
self._resolveErrors.push({ err: err, dep: dep, filepath: filepath }); | ||
// do not store result when an error occurs | ||
if(complete == expected) { | ||
// store result | ||
cache.file(filepath).data(resultKey, result); | ||
return onDone(null, result); | ||
@@ -109,23 +104,17 @@ } | ||
// browser-resolve may replace specific files with different names | ||
if (self.onRename) { | ||
if(self.onRename) { | ||
var canonical = nodeResolve.sync(dep, { basedir: path.dirname(filepath) }); | ||
if(canonical != normalized) { | ||
self.onRename(canonical, normalized); | ||
// do not store result when an error occurs | ||
if(!hasErrors) { | ||
cache.file(filepath).data(renameKey, [ canonical, normalized ]); | ||
} | ||
cache.file(filepath).data(renameKey, [ canonical, normalized ]); | ||
} | ||
} | ||
// console.log('RESOLVE', normalized); | ||
result.push(path.normalize(normalized)); | ||
if(complete == expected) { | ||
// do not store result when an error occurs | ||
if(!hasErrors) { | ||
cache.file(filepath).data(resultKey, result); | ||
} else { | ||
log.debug('Skipping cache due to errors:', filepath); | ||
} | ||
// store result | ||
cache.file(filepath).data(resultKey, result); | ||
log.debug('Result:', filepath, result); | ||
return onDone(null, result); | ||
@@ -144,31 +133,8 @@ } | ||
var oldAdd = DetectiveList.prototype.add; | ||
DetectiveList.prototype.add = function(filepath) { | ||
// since the core find logic does not deal with directories, make sure the core add | ||
// is called only with files, even if the input was a set of directories | ||
var self = this; | ||
if (Array.isArray(filepath)) { | ||
filepath.forEach(function(filepath) { | ||
self.add(filepath); | ||
}); | ||
return this; | ||
} | ||
var stat = fs.statSync(filepath); | ||
if (stat.isDirectory()) { | ||
var basepath = filepath + (filepath[filepath.length - 1] !== path.sep ? path.sep : ''); | ||
return this.add(fs.readdirSync(basepath).map(function(f) { | ||
return basepath + f; | ||
})); | ||
} else { | ||
return oldAdd.apply(this, Array.prototype.slice.apply(arguments)); | ||
} | ||
}; | ||
var oldExec = DetectiveList.prototype.exec; | ||
DetectiveList.prototype.exec = function() { | ||
this._resolveErrors = []; | ||
return oldExec.apply(this, Array.prototype.slice.apply(arguments)); | ||
oldExec.apply(this, Array.prototype.slice.apply(arguments)); | ||
}; | ||
module.exports = DetectiveList; |
@@ -35,10 +35,2 @@ /* | ||
} | ||
} else { | ||
// module internal file | ||
var ifile = p && p.split('/'); | ||
if(ifile.length > 1 && r.m[context][ifile[0]]) { | ||
context = r.m[context][ifile[0]].c; | ||
path = r.resolve(ifile.slice(1).join('/'), context); | ||
mod = r.m[context][path]; | ||
} | ||
} | ||
@@ -45,0 +37,0 @@ if (!mod) { |
@@ -1,1 +0,1 @@ | ||
var r=function(){var e="function"==typeof require&&require,r=function(n,o,u){o||(o=0);var i=r.resolve(n,o),t=r.m[o][i];if(!t&&e){if(t=e(i))return t}else if(t&&t.c){if(o=t.c,i=t.m,t=r.m[o][t.m],!t)throw new Error('failed to require "'+i+'" from '+o)}else{var f=n&&n.split("/");f.length>1&&r.m[o][f[0]]&&(o=r.m[o][f[0]].c,i=r.resolve(f.slice(1).join("/"),o),t=r.m[o][i])}if(!t)throw new Error('failed to require "'+n+'" from '+u);return t.exports||(t.exports={},t.call(t.exports,t,t.exports,r.relative(i,o))),t.exports};return r.resolve=function(e,i){var n=e,t=e+".js",o=e+"/index.js";return r.m[i][t]&&t?t:r.m[i][o]&&o?o:n},r.relative=function(e,t){return function(i){if("."!=i.charAt(0))return r(i,t,e);var o=e.split("/"),u=i.split("/");o.pop();for(var n=0;n<u.length;n++){var f=u[n];".."==f?o.pop():"."!=f&&o.push(f)}return r(o.join("/"),t,e)}},r}(); | ||
var r=function(){var e="function"==typeof require&&require,r=function(i,o,u){o||(o=0);var n=r.resolve(i,o),t=r.m[o][n];if(!t&&e){if(t=e(n))return t}else if(t&&t.c&&(o=t.c,n=t.m,t=r.m[o][t.m],!t))throw new Error('failed to require "'+n+'" from '+o);if(!t)throw new Error('failed to require "'+i+'" from '+u);return t.exports||(t.exports={},t.call(t.exports,t,t.exports,r.relative(n,o))),t.exports};return r.resolve=function(e,n){var i=e,t=e+".js",o=e+"/index.js";return r.m[n][t]&&t?t:r.m[n][o]&&o?o:i},r.relative=function(e,t){return function(n){if("."!=n.charAt(0))return r(n,t,e);var o=e.split("/"),f=n.split("/");o.pop();for(var i=0;i<f.length;i++){var u=f[i];".."==u?o.pop():"."!=u&&o.push(u)}return r(o.join("/"),t,e)}},r}(); |
{ | ||
"name": "gluejs", | ||
"description": "Build CommonJS modules for the browser via a chainable API", | ||
"version": "2.3.8", | ||
"version": "2.3.9", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Mikito Takada", |
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
70
704100
11828