advanced-require
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -12,33 +12,34 @@ /** | ||
*/ | ||
require( 'abstract' ).createModel( function advanced_require( model, prototype ) { | ||
require( 'abstract' ).createModel( module.exports = function advancedRequire( model, prototype ) { | ||
// Model Exposure | ||
module.exports = model; | ||
// Construct Model only once. | ||
if( module.loaded ) { | ||
return advancedRequire; | ||
} | ||
// Configure module | ||
model.set( 'create_method', 'load' ); | ||
// Private Modules. | ||
var util = require( 'util' ); | ||
var inherits = require( 'util' ).inherits; | ||
var _extend = require( 'util' )._extend; | ||
var join_path = require( 'path' ).join; | ||
var fs = require( 'fs' ); | ||
var include = require( 'include-all' ); | ||
// Model Resources | ||
// model.use( require( 'eventemitter2' ).EventEmitter2.prototype ); | ||
// Properties: Constructor | ||
model.defineProperties( model, { | ||
modules: function( dir, opts ) { | ||
return model.load( dir, opts ); | ||
advancedRequire.defineProperties( model, { | ||
include: include, | ||
realpath: function realpath() { | ||
var _path = arguments.length > 1 ? join_path.apply( {}, arguments ) : arguments[0]; | ||
return fs.realpathSync( _path ); | ||
}, | ||
files: function() { | ||
return model.load( dir, opts ); | ||
watchTree: function watchTree( root, options, callback ) { | ||
return require( 'watch' ).watchTree( root, options, callback ); | ||
}, | ||
monitor: function() { | ||
return model.load( dir, opts ); | ||
createMonitor: function createMonitor( root, options, callback ) { | ||
return require( 'watch' ).createMonitor( root, options, callback ); | ||
}, | ||
utility: require( 'abstract' ).utility | ||
//maxListeners: 50, | ||
//delimiter: ':', | ||
//wildcard: true, | ||
//listenerTree: {} | ||
}); | ||
// Instance Constructor | ||
model.defineInstance( function load( dir, opts, depth ) { | ||
advancedRequire.defineConstructor( function load( dir, opts, depth ) { | ||
var Instance = this; | ||
@@ -48,10 +49,11 @@ | ||
opts = require( 'abstract' ).utility.defaults( opts || {}, { | ||
opts = _extend({ | ||
'duplicates': false, | ||
'recurse': true, | ||
'ignoreDotFiles': true, | ||
'depth': 5, | ||
'ignore': [ '.svn', '.DS_Store' ], | ||
'ignore': [ '.svn', '.git', '.DS_Store' ], | ||
'extensions': Object.keys( require.extensions ), | ||
'logger': undefined | ||
}); | ||
}, opts ); | ||
@@ -106,4 +108,14 @@ // Ensure Extensions are Always in Array Form | ||
(filesForBase[base] = filesForBase[base] || []).push( file ); | ||
// Skip "dot" files | ||
if( opts.ignoreDotFiles && require( 'path' ).basename( base )[0] === '.' ) { | ||
continue; | ||
} | ||
filesForBase[base] = filesForBase[base] || []; | ||
if( filesForBase[base].push ) { | ||
filesForBase[base].push( file ); | ||
} | ||
} | ||
@@ -110,0 +122,0 @@ |
{ | ||
"name": "advanced-require", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Require things in Node.js.", | ||
@@ -39,2 +39,4 @@ "author": { | ||
"abstract": "*", | ||
"include-all": "*", | ||
"watch": "*", | ||
"lodash": "*", | ||
@@ -50,3 +52,3 @@ "object-settings": "*" | ||
}, | ||
"readmeFilename": "Readme.md" | ||
"readmeFilename": "readme.md" | ||
} |
@@ -7,107 +7,133 @@ /* automatically generated by JSCoverage - do not edit */ | ||
_$jscoverage['advanced-require.js'][15] = 0; | ||
_$jscoverage['advanced-require.js'][18] = 0; | ||
_$jscoverage['advanced-require.js'][16] = 0; | ||
_$jscoverage['advanced-require.js'][20] = 0; | ||
_$jscoverage['advanced-require.js'][21] = 0; | ||
_$jscoverage['advanced-require.js'][22] = 0; | ||
_$jscoverage['advanced-require.js'][23] = 0; | ||
_$jscoverage['advanced-require.js'][24] = 0; | ||
_$jscoverage['advanced-require.js'][26] = 0; | ||
_$jscoverage['advanced-require.js'][29] = 0; | ||
_$jscoverage['advanced-require.js'][25] = 0; | ||
_$jscoverage['advanced-require.js'][28] = 0; | ||
_$jscoverage['advanced-require.js'][31] = 0; | ||
_$jscoverage['advanced-require.js'][32] = 0; | ||
_$jscoverage['advanced-require.js'][42] = 0; | ||
_$jscoverage['advanced-require.js'][35] = 0; | ||
_$jscoverage['advanced-require.js'][38] = 0; | ||
_$jscoverage['advanced-require.js'][43] = 0; | ||
_$jscoverage['advanced-require.js'][45] = 0; | ||
_$jscoverage['advanced-require.js'][47] = 0; | ||
_$jscoverage['advanced-require.js'][57] = 0; | ||
_$jscoverage['advanced-require.js'][58] = 0; | ||
_$jscoverage['advanced-require.js'][44] = 0; | ||
_$jscoverage['advanced-require.js'][46] = 0; | ||
_$jscoverage['advanced-require.js'][48] = 0; | ||
_$jscoverage['advanced-require.js'][59] = 0; | ||
_$jscoverage['advanced-require.js'][60] = 0; | ||
_$jscoverage['advanced-require.js'][62] = 0; | ||
_$jscoverage['advanced-require.js'][65] = 0; | ||
_$jscoverage['advanced-require.js'][66] = 0; | ||
_$jscoverage['advanced-require.js'][64] = 0; | ||
_$jscoverage['advanced-require.js'][67] = 0; | ||
_$jscoverage['advanced-require.js'][68] = 0; | ||
_$jscoverage['advanced-require.js'][69] = 0; | ||
_$jscoverage['advanced-require.js'][74] = 0; | ||
_$jscoverage['advanced-require.js'][70] = 0; | ||
_$jscoverage['advanced-require.js'][71] = 0; | ||
_$jscoverage['advanced-require.js'][76] = 0; | ||
_$jscoverage['advanced-require.js'][77] = 0; | ||
_$jscoverage['advanced-require.js'][80] = 0; | ||
_$jscoverage['advanced-require.js'][86] = 0; | ||
_$jscoverage['advanced-require.js'][78] = 0; | ||
_$jscoverage['advanced-require.js'][79] = 0; | ||
_$jscoverage['advanced-require.js'][82] = 0; | ||
_$jscoverage['advanced-require.js'][88] = 0; | ||
_$jscoverage['advanced-require.js'][89] = 0; | ||
_$jscoverage['advanced-require.js'][90] = 0; | ||
_$jscoverage['advanced-require.js'][91] = 0; | ||
_$jscoverage['advanced-require.js'][92] = 0; | ||
_$jscoverage['advanced-require.js'][95] = 0; | ||
_$jscoverage['advanced-require.js'][96] = 0; | ||
_$jscoverage['advanced-require.js'][100] = 0; | ||
_$jscoverage['advanced-require.js'][101] = 0; | ||
_$jscoverage['advanced-require.js'][104] = 0; | ||
_$jscoverage['advanced-require.js'][93] = 0; | ||
_$jscoverage['advanced-require.js'][94] = 0; | ||
_$jscoverage['advanced-require.js'][97] = 0; | ||
_$jscoverage['advanced-require.js'][98] = 0; | ||
_$jscoverage['advanced-require.js'][102] = 0; | ||
_$jscoverage['advanced-require.js'][103] = 0; | ||
_$jscoverage['advanced-require.js'][107] = 0; | ||
_$jscoverage['advanced-require.js'][108] = 0; | ||
_$jscoverage['advanced-require.js'][111] = 0; | ||
_$jscoverage['advanced-require.js'][112] = 0; | ||
_$jscoverage['advanced-require.js'][115] = 0; | ||
_$jscoverage['advanced-require.js'][116] = 0; | ||
_$jscoverage['advanced-require.js'][118] = 0; | ||
_$jscoverage['advanced-require.js'][119] = 0; | ||
_$jscoverage['advanced-require.js'][113] = 0; | ||
_$jscoverage['advanced-require.js'][114] = 0; | ||
_$jscoverage['advanced-require.js'][120] = 0; | ||
_$jscoverage['advanced-require.js'][122] = 0; | ||
_$jscoverage['advanced-require.js'][123] = 0; | ||
_$jscoverage['advanced-require.js'][124] = 0; | ||
_$jscoverage['advanced-require.js'][126] = 0; | ||
_$jscoverage['advanced-require.js'][129] = 0; | ||
_$jscoverage['advanced-require.js'][127] = 0; | ||
_$jscoverage['advanced-require.js'][128] = 0; | ||
_$jscoverage['advanced-require.js'][130] = 0; | ||
_$jscoverage['advanced-require.js'][135] = 0; | ||
_$jscoverage['advanced-require.js'][139] = 0; | ||
_$jscoverage['advanced-require.js'][140] = 0; | ||
_$jscoverage['advanced-require.js'][143] = 0; | ||
_$jscoverage['advanced-require.js'][145] = 0; | ||
_$jscoverage['advanced-require.js'][146] = 0; | ||
_$jscoverage['advanced-require.js'][149] = 0; | ||
_$jscoverage['advanced-require.js'][150] = 0; | ||
_$jscoverage['advanced-require.js'][131] = 0; | ||
_$jscoverage['advanced-require.js'][132] = 0; | ||
_$jscoverage['advanced-require.js'][134] = 0; | ||
_$jscoverage['advanced-require.js'][136] = 0; | ||
_$jscoverage['advanced-require.js'][138] = 0; | ||
_$jscoverage['advanced-require.js'][141] = 0; | ||
_$jscoverage['advanced-require.js'][142] = 0; | ||
_$jscoverage['advanced-require.js'][147] = 0; | ||
_$jscoverage['advanced-require.js'][151] = 0; | ||
_$jscoverage['advanced-require.js'][152] = 0; | ||
_$jscoverage['advanced-require.js'][154] = 0; | ||
_$jscoverage['advanced-require.js'][156] = 0; | ||
_$jscoverage['advanced-require.js'][155] = 0; | ||
_$jscoverage['advanced-require.js'][157] = 0; | ||
_$jscoverage['advanced-require.js'][158] = 0; | ||
_$jscoverage['advanced-require.js'][159] = 0; | ||
_$jscoverage['advanced-require.js'][161] = 0; | ||
_$jscoverage['advanced-require.js'][162] = 0; | ||
_$jscoverage['advanced-require.js'][164] = 0; | ||
_$jscoverage['advanced-require.js'][165] = 0; | ||
_$jscoverage['advanced-require.js'][169] = 0; | ||
_$jscoverage['advanced-require.js'][166] = 0; | ||
_$jscoverage['advanced-require.js'][168] = 0; | ||
_$jscoverage['advanced-require.js'][170] = 0; | ||
_$jscoverage['advanced-require.js'][178] = 0; | ||
_$jscoverage['advanced-require.js'][180] = 0; | ||
_$jscoverage['advanced-require.js'][204] = 0; | ||
_$jscoverage['advanced-require.js'][171] = 0; | ||
_$jscoverage['advanced-require.js'][176] = 0; | ||
_$jscoverage['advanced-require.js'][177] = 0; | ||
_$jscoverage['advanced-require.js'][181] = 0; | ||
_$jscoverage['advanced-require.js'][182] = 0; | ||
_$jscoverage['advanced-require.js'][190] = 0; | ||
_$jscoverage['advanced-require.js'][192] = 0; | ||
_$jscoverage['advanced-require.js'][216] = 0; | ||
} | ||
_$jscoverage['advanced-require.js'][12]++; | ||
require("abstract").createModel((function advanced_require(model, prototype) { | ||
require("abstract").createModel(module.exports = (function advancedRequire(model, prototype) { | ||
_$jscoverage['advanced-require.js'][15]++; | ||
module.exports = model; | ||
_$jscoverage['advanced-require.js'][18]++; | ||
model.set("create_method", "load"); | ||
if (module.loaded) { | ||
_$jscoverage['advanced-require.js'][16]++; | ||
return advancedRequire; | ||
} | ||
_$jscoverage['advanced-require.js'][20]++; | ||
var util = require("util"); | ||
_$jscoverage['advanced-require.js'][21]++; | ||
var inherits = require("util").inherits; | ||
_$jscoverage['advanced-require.js'][22]++; | ||
var _extend = require("util")._extend; | ||
_$jscoverage['advanced-require.js'][23]++; | ||
var join_path = require("path").join; | ||
_$jscoverage['advanced-require.js'][24]++; | ||
model.defineProperties(model, {modules: (function (dir, opts) { | ||
_$jscoverage['advanced-require.js'][26]++; | ||
return model.load(dir, opts); | ||
}), files: (function () { | ||
_$jscoverage['advanced-require.js'][29]++; | ||
return model.load(dir, opts); | ||
}), monitor: (function () { | ||
var fs = require("fs"); | ||
_$jscoverage['advanced-require.js'][25]++; | ||
var include = require("include-all"); | ||
_$jscoverage['advanced-require.js'][28]++; | ||
advancedRequire.defineProperties(model, {include: include, realpath: (function realpath() { | ||
_$jscoverage['advanced-require.js'][31]++; | ||
var _path = arguments.length > 1? join_path.apply({}, arguments): arguments[0]; | ||
_$jscoverage['advanced-require.js'][32]++; | ||
return model.load(dir, opts); | ||
}), utility: require("abstract").utility}); | ||
_$jscoverage['advanced-require.js'][42]++; | ||
model.defineInstance((function load(dir, opts, depth) { | ||
return fs.realpathSync(_path); | ||
}), watchTree: (function watchTree(root, options, callback) { | ||
_$jscoverage['advanced-require.js'][35]++; | ||
return require("watch").watchTree(root, options, callback); | ||
}), createMonitor: (function createMonitor(root, options, callback) { | ||
_$jscoverage['advanced-require.js'][38]++; | ||
return require("watch").createMonitor(root, options, callback); | ||
})}); | ||
_$jscoverage['advanced-require.js'][43]++; | ||
advancedRequire.defineConstructor((function load(dir, opts, depth) { | ||
_$jscoverage['advanced-require.js'][44]++; | ||
var Instance = this; | ||
_$jscoverage['advanced-require.js'][45]++; | ||
_$jscoverage['advanced-require.js'][46]++; | ||
depth = depth + 1 || 0; | ||
_$jscoverage['advanced-require.js'][47]++; | ||
opts = require("abstract").utility.defaults(opts || {}, {"duplicates": false, "recurse": true, "depth": 5, "ignore": [".svn", ".DS_Store"], "extensions": Object.keys(require.extensions), "logger": undefined}); | ||
_$jscoverage['advanced-require.js'][57]++; | ||
_$jscoverage['advanced-require.js'][48]++; | ||
opts = _extend({"duplicates": false, "recurse": true, "ignoreDotFiles": true, "depth": 5, "ignore": [".svn", ".git", ".DS_Store"], "extensions": Object.keys(require.extensions), "logger": undefined}, opts); | ||
_$jscoverage['advanced-require.js'][59]++; | ||
opts.extensions = typeof opts.extensions === "string"? [opts.extensions]: opts.extensions; | ||
_$jscoverage['advanced-require.js'][58]++; | ||
_$jscoverage['advanced-require.js'][60]++; | ||
opts.ignore = typeof opts.ignore === "string"? [opts.ignore]: opts.ignore; | ||
_$jscoverage['advanced-require.js'][60]++; | ||
_$jscoverage['advanced-require.js'][62]++; | ||
var files = []; | ||
_$jscoverage['advanced-require.js'][62]++; | ||
_$jscoverage['advanced-require.js'][64]++; | ||
try { | ||
_$jscoverage['advanced-require.js'][65]++; | ||
_$jscoverage['advanced-require.js'][67]++; | ||
dir = require("path").resolve(dir); | ||
_$jscoverage['advanced-require.js'][66]++; | ||
_$jscoverage['advanced-require.js'][68]++; | ||
files = require("fs").readdirSync(dir); | ||
_$jscoverage['advanced-require.js'][68]++; | ||
_$jscoverage['advanced-require.js'][70]++; | ||
if (! files.length) { | ||
_$jscoverage['advanced-require.js'][69]++; | ||
_$jscoverage['advanced-require.js'][71]++; | ||
throw new Error("No files found."); | ||
@@ -117,62 +143,72 @@ } | ||
catch (error) { | ||
_$jscoverage['advanced-require.js'][74]++; | ||
_$jscoverage['advanced-require.js'][76]++; | ||
if (error.code === "ENOENT") { | ||
_$jscoverage['advanced-require.js'][76]++; | ||
_$jscoverage['advanced-require.js'][78]++; | ||
if (opts.logger && opts.logger.error) { | ||
_$jscoverage['advanced-require.js'][77]++; | ||
_$jscoverage['advanced-require.js'][79]++; | ||
opts.logger.error(error.message); | ||
} | ||
_$jscoverage['advanced-require.js'][80]++; | ||
_$jscoverage['advanced-require.js'][82]++; | ||
return; | ||
} | ||
} | ||
_$jscoverage['advanced-require.js'][86]++; | ||
_$jscoverage['advanced-require.js'][88]++; | ||
var filesForBase = {}; | ||
_$jscoverage['advanced-require.js'][88]++; | ||
_$jscoverage['advanced-require.js'][90]++; | ||
for (var i = 0; i < files.length; i++) { | ||
_$jscoverage['advanced-require.js'][89]++; | ||
_$jscoverage['advanced-require.js'][91]++; | ||
var file = files[i]; | ||
_$jscoverage['advanced-require.js'][91]++; | ||
_$jscoverage['advanced-require.js'][93]++; | ||
var ext = require("path").extname(file); | ||
_$jscoverage['advanced-require.js'][92]++; | ||
_$jscoverage['advanced-require.js'][94]++; | ||
var base = require("path").basename(file, ext); | ||
_$jscoverage['advanced-require.js'][95]++; | ||
_$jscoverage['advanced-require.js'][97]++; | ||
if (ext && opts.extensions.indexOf(ext) < 0) { | ||
_$jscoverage['advanced-require.js'][96]++; | ||
_$jscoverage['advanced-require.js'][98]++; | ||
continue; | ||
} | ||
_$jscoverage['advanced-require.js'][100]++; | ||
_$jscoverage['advanced-require.js'][102]++; | ||
if (base && opts.ignore.indexOf(base) > -1) { | ||
_$jscoverage['advanced-require.js'][101]++; | ||
_$jscoverage['advanced-require.js'][103]++; | ||
continue; | ||
} | ||
_$jscoverage['advanced-require.js'][104]++; | ||
(filesForBase[base] = filesForBase[base] || []).push(file); | ||
_$jscoverage['advanced-require.js'][107]++; | ||
if (opts.ignoreDotFiles && require("path").basename(base)[0] === ".") { | ||
_$jscoverage['advanced-require.js'][108]++; | ||
continue; | ||
} | ||
_$jscoverage['advanced-require.js'][111]++; | ||
filesForBase[base] = filesForBase[base] || []; | ||
_$jscoverage['advanced-require.js'][113]++; | ||
if (filesForBase[base].push) { | ||
_$jscoverage['advanced-require.js'][114]++; | ||
filesForBase[base].push(file); | ||
} | ||
} | ||
_$jscoverage['advanced-require.js'][108]++; | ||
_$jscoverage['advanced-require.js'][120]++; | ||
for (var base in filesForBase) { | ||
_$jscoverage['advanced-require.js'][111]++; | ||
_$jscoverage['advanced-require.js'][123]++; | ||
if (! filesForBase.hasOwnProperty(base)) { | ||
_$jscoverage['advanced-require.js'][112]++; | ||
_$jscoverage['advanced-require.js'][124]++; | ||
continue; | ||
} | ||
_$jscoverage['advanced-require.js'][115]++; | ||
_$jscoverage['advanced-require.js'][127]++; | ||
var files = filesForBase[base]; | ||
_$jscoverage['advanced-require.js'][116]++; | ||
_$jscoverage['advanced-require.js'][128]++; | ||
var filesMinusDirs = {}; | ||
_$jscoverage['advanced-require.js'][118]++; | ||
_$jscoverage['advanced-require.js'][130]++; | ||
for (var i = 0; i < files.length; i++) { | ||
_$jscoverage['advanced-require.js'][119]++; | ||
_$jscoverage['advanced-require.js'][131]++; | ||
var file = files[i]; | ||
_$jscoverage['advanced-require.js'][120]++; | ||
_$jscoverage['advanced-require.js'][132]++; | ||
var path = require("path").resolve(dir, file); | ||
_$jscoverage['advanced-require.js'][122]++; | ||
_$jscoverage['advanced-require.js'][134]++; | ||
if (require("fs").statSync(path).isDirectory()) { | ||
_$jscoverage['advanced-require.js'][124]++; | ||
_$jscoverage['advanced-require.js'][136]++; | ||
if (opts.recurse && opts.depth >= depth) { | ||
_$jscoverage['advanced-require.js'][126]++; | ||
_$jscoverage['advanced-require.js'][138]++; | ||
Instance[base] = model.load(path, opts, depth); | ||
_$jscoverage['advanced-require.js'][129]++; | ||
_$jscoverage['advanced-require.js'][141]++; | ||
if (opts.duplicates) { | ||
_$jscoverage['advanced-require.js'][130]++; | ||
_$jscoverage['advanced-require.js'][142]++; | ||
Instance[file] = Instance[base]; | ||
@@ -183,31 +219,31 @@ } | ||
else { | ||
_$jscoverage['advanced-require.js'][135]++; | ||
_$jscoverage['advanced-require.js'][147]++; | ||
filesMinusDirs[file] = path; | ||
} | ||
} | ||
_$jscoverage['advanced-require.js'][139]++; | ||
_$jscoverage['advanced-require.js'][151]++; | ||
if (Instance[base] && ! opts.duplicates) { | ||
_$jscoverage['advanced-require.js'][140]++; | ||
_$jscoverage['advanced-require.js'][152]++; | ||
continue; | ||
} | ||
_$jscoverage['advanced-require.js'][143]++; | ||
_$jscoverage['advanced-require.js'][155]++; | ||
opts.extensions.forEach((function (ext) { | ||
_$jscoverage['advanced-require.js'][145]++; | ||
_$jscoverage['advanced-require.js'][157]++; | ||
if (! require.extensions.hasOwnProperty(ext)) { | ||
_$jscoverage['advanced-require.js'][146]++; | ||
_$jscoverage['advanced-require.js'][158]++; | ||
return; | ||
} | ||
_$jscoverage['advanced-require.js'][149]++; | ||
_$jscoverage['advanced-require.js'][161]++; | ||
var file = base + ext; | ||
_$jscoverage['advanced-require.js'][150]++; | ||
_$jscoverage['advanced-require.js'][162]++; | ||
var path = filesMinusDirs[file]; | ||
_$jscoverage['advanced-require.js'][152]++; | ||
_$jscoverage['advanced-require.js'][164]++; | ||
if (path) { | ||
_$jscoverage['advanced-require.js'][154]++; | ||
_$jscoverage['advanced-require.js'][166]++; | ||
if (opts.duplicates) { | ||
_$jscoverage['advanced-require.js'][156]++; | ||
_$jscoverage['advanced-require.js'][168]++; | ||
Instance[file] = require(path); | ||
_$jscoverage['advanced-require.js'][158]++; | ||
_$jscoverage['advanced-require.js'][170]++; | ||
if (! Instance[base]) { | ||
_$jscoverage['advanced-require.js'][159]++; | ||
_$jscoverage['advanced-require.js'][171]++; | ||
Instance[base] = Instance[file]; | ||
@@ -217,11 +253,11 @@ } | ||
else { | ||
_$jscoverage['advanced-require.js'][164]++; | ||
_$jscoverage['advanced-require.js'][176]++; | ||
try { | ||
_$jscoverage['advanced-require.js'][165]++; | ||
_$jscoverage['advanced-require.js'][177]++; | ||
Instance[base] = require(path); | ||
} | ||
catch (error) { | ||
_$jscoverage['advanced-require.js'][169]++; | ||
_$jscoverage['advanced-require.js'][181]++; | ||
if (opts.logger && opts.logger.error) { | ||
_$jscoverage['advanced-require.js'][170]++; | ||
_$jscoverage['advanced-require.js'][182]++; | ||
opts.logger.error(error, path); | ||
@@ -231,5 +267,5 @@ } | ||
} | ||
_$jscoverage['advanced-require.js'][178]++; | ||
_$jscoverage['advanced-require.js'][190]++; | ||
if (Instance[base]) { | ||
_$jscoverage['advanced-require.js'][180]++; | ||
_$jscoverage['advanced-require.js'][192]++; | ||
Object.defineProperties(Instance[base], {"__path": {"enumerable": false, "writable": true, "configurable": true, "value": require.resolve(path)}, "__directory": {"enumerable": false, "configurable": true, "writable": true, "value": require("path").dirname(require.resolve(path))}}); | ||
@@ -240,6 +276,6 @@ } | ||
} | ||
_$jscoverage['advanced-require.js'][204]++; | ||
_$jscoverage['advanced-require.js'][216]++; | ||
return Instance; | ||
})); | ||
})); | ||
_$jscoverage['advanced-require.js'].source = ["/**"," * AdvancedRequire Module"," *"," * -"," *"," * @module advanced-require"," * @constructor"," * @author potanin@UD"," * @date 7/12/13"," * @type {Object}"," */","require( 'abstract' ).createModel( function advanced_require( model, prototype ) {",""," // Model Exposure"," module.exports = model;",""," // Configure module"," model.set( 'create_method', 'load' );",""," // Model Resources"," // model.use( require( 'eventemitter2' ).EventEmitter2.prototype );",""," // Properties: Constructor"," model.defineProperties( model, {"," modules: function( dir, opts ) {"," return model.load( dir, opts );"," },"," files: function() {"," return model.load( dir, opts );"," },"," monitor: function() {"," return model.load( dir, opts );"," },"," utility: require( 'abstract' ).utility"," //maxListeners: 50,"," //delimiter: ':',"," //wildcard: true,"," //listenerTree: {}"," });"," "," // Instance Constructor"," model.defineInstance( function load( dir, opts, depth ) {"," var Instance = this;",""," depth = depth + 1 || 0;",""," opts = require( 'abstract' ).utility.defaults( opts || {}, {"," 'duplicates': false,"," 'recurse': true,"," 'depth': 5,"," 'ignore': [ '.svn', '.DS_Store' ],"," 'extensions': Object.keys( require.extensions ),"," 'logger': undefined"," });",""," // Ensure Extensions are Always in Array Form"," opts.extensions = typeof opts.extensions === 'string' ? [ opts.extensions ] : opts.extensions;"," opts.ignore = typeof opts.ignore === 'string' ? [ opts.ignore ] : opts.ignore;",""," var files = [];",""," try {",""," // resolve the path to an absolute one:"," dir = require( 'path' ).resolve( dir );"," files = require( 'fs' ).readdirSync( dir );",""," if( !files.length ) {"," throw new Error( 'No files found.' )"," }",""," } catch( error ) {",""," if( error.code === 'ENOENT' ) {",""," if( opts.logger && opts.logger.error ) {"," opts.logger.error( error.message );"," }",""," return;",""," }",""," }",""," var filesForBase = {};",""," for( var i = 0; i < files.length; i++ ) {"," var file = files[i];",""," var ext = require( 'path' ).extname( file );"," var base = require( 'path' ).basename( file, ext );",""," // Only Get Selected File Extensions"," if( ext && opts.extensions.indexOf( ext ) < 0 ) {"," continue;"," }",""," // Explicitly Exclude Specific File Names"," if( base && opts.ignore.indexOf( base ) > -1 ) {"," continue;"," }",""," (filesForBase[base] = filesForBase[base] || []).push( file );",""," }",""," for( var base in filesForBase ) {",""," // protect against enumerable object prototype extensions:"," if( !filesForBase.hasOwnProperty( base ) ) {"," continue;"," }",""," var files = filesForBase[base];"," var filesMinusDirs = {};",""," for( var i = 0; i < files.length; i++ ) {"," var file = files[i];"," var path = require( 'path' ).resolve( dir, file );",""," if( require( 'fs' ).statSync( path ).isDirectory() ) {",""," if( opts.recurse && opts.depth >= depth ) {",""," Instance[base] = model.load( path, opts, depth );",""," // if duplicates are wanted, key off the full name too:"," if( opts.duplicates ) {"," Instance[file] = Instance[base];"," }"," }",""," } else {"," filesMinusDirs[file] = path;"," }"," }",""," if( Instance[base] && !opts.duplicates ) {"," continue;"," }",""," opts.extensions.forEach( function( ext ) {",""," if( !require.extensions.hasOwnProperty( ext ) ) {"," return;"," }",""," var file = base + ext;"," var path = filesMinusDirs[file];",""," if( path ) {",""," if( opts.duplicates ) {",""," Instance[file] = require( path );",""," if( !Instance[base] ) {"," Instance[base] = Instance[file];"," }",""," } else {",""," try {"," Instance[base] = require( path );",""," } catch ( error ) {",""," if( opts.logger && opts.logger.error ) {"," opts.logger.error( error, path )"," }",""," }","",""," }",""," if( Instance[base] ) {",""," Object.defineProperties( Instance[base], {"," '__path': {"," 'enumerable': false,"," 'writable': true,"," 'configurable': true,"," 'value': require.resolve( path )"," },"," '__directory': {"," 'enumerable': false,"," 'configurable': true,"," 'writable': true,"," 'value': require( 'path' ).dirname( require.resolve( path ) )"," }"," });","",""," }",""," }",""," });",""," }",""," return Instance;",""," });"," ","});",""]; | ||
_$jscoverage['advanced-require.js'].source = ["/**"," * AdvancedRequire Module"," *"," * -"," *"," * @module advanced-require"," * @constructor"," * @author potanin@UD"," * @date 7/12/13"," * @type {Object}"," */","require( 'abstract' ).createModel( module.exports = function advancedRequire( model, prototype ) {",""," // Construct Model only once."," if( module.loaded ) {"," return advancedRequire;"," }",""," // Private Modules."," var util = require( 'util' );"," var inherits = require( 'util' ).inherits;"," var _extend = require( 'util' )._extend;"," var join_path = require( 'path' ).join;"," var fs = require( 'fs' );"," var include = require( 'include-all' );",""," // Properties: Constructor"," advancedRequire.defineProperties( model, {"," include: include,"," realpath: function realpath() {"," var _path = arguments.length > 1 ? join_path.apply( {}, arguments ) : arguments[0];"," return fs.realpathSync( _path );"," },"," watchTree: function watchTree( root, options, callback ) {"," return require( 'watch' ).watchTree( root, options, callback );"," },"," createMonitor: function createMonitor( root, options, callback ) {"," return require( 'watch' ).createMonitor( root, options, callback );"," },"," });",""," // Instance Constructor"," advancedRequire.defineConstructor( function load( dir, opts, depth ) {"," var Instance = this;",""," depth = depth + 1 || 0;",""," opts = _extend({"," 'duplicates': false,"," 'recurse': true,"," 'ignoreDotFiles': true,"," 'depth': 5,"," 'ignore': [ '.svn', '.git', '.DS_Store' ],"," 'extensions': Object.keys( require.extensions ),"," 'logger': undefined"," }, opts );",""," // Ensure Extensions are Always in Array Form"," opts.extensions = typeof opts.extensions === 'string' ? [ opts.extensions ] : opts.extensions;"," opts.ignore = typeof opts.ignore === 'string' ? [ opts.ignore ] : opts.ignore;",""," var files = [];",""," try {",""," // resolve the path to an absolute one:"," dir = require( 'path' ).resolve( dir );"," files = require( 'fs' ).readdirSync( dir );",""," if( !files.length ) {"," throw new Error( 'No files found.' )"," }",""," } catch( error ) {",""," if( error.code === 'ENOENT' ) {",""," if( opts.logger && opts.logger.error ) {"," opts.logger.error( error.message );"," }",""," return;",""," }",""," }",""," var filesForBase = {};",""," for( var i = 0; i < files.length; i++ ) {"," var file = files[i];",""," var ext = require( 'path' ).extname( file );"," var base = require( 'path' ).basename( file, ext );",""," // Only Get Selected File Extensions"," if( ext && opts.extensions.indexOf( ext ) < 0 ) {"," continue;"," }",""," // Explicitly Exclude Specific File Names"," if( base && opts.ignore.indexOf( base ) > -1 ) {"," continue;"," }",""," // Skip \"dot\" files"," if( opts.ignoreDotFiles && require( 'path' ).basename( base )[0] === '.' ) {"," continue;"," }",""," filesForBase[base] = filesForBase[base] || [];",""," if( filesForBase[base].push ) {"," filesForBase[base].push( file );",""," }",""," }",""," for( var base in filesForBase ) {",""," // protect against enumerable object prototype extensions:"," if( !filesForBase.hasOwnProperty( base ) ) {"," continue;"," }",""," var files = filesForBase[base];"," var filesMinusDirs = {};",""," for( var i = 0; i < files.length; i++ ) {"," var file = files[i];"," var path = require( 'path' ).resolve( dir, file );",""," if( require( 'fs' ).statSync( path ).isDirectory() ) {",""," if( opts.recurse && opts.depth >= depth ) {",""," Instance[base] = model.load( path, opts, depth );",""," // if duplicates are wanted, key off the full name too:"," if( opts.duplicates ) {"," Instance[file] = Instance[base];"," }"," }",""," } else {"," filesMinusDirs[file] = path;"," }"," }",""," if( Instance[base] && !opts.duplicates ) {"," continue;"," }",""," opts.extensions.forEach( function( ext ) {",""," if( !require.extensions.hasOwnProperty( ext ) ) {"," return;"," }",""," var file = base + ext;"," var path = filesMinusDirs[file];",""," if( path ) {",""," if( opts.duplicates ) {",""," Instance[file] = require( path );",""," if( !Instance[base] ) {"," Instance[base] = Instance[file];"," }",""," } else {",""," try {"," Instance[base] = require( path );",""," } catch ( error ) {",""," if( opts.logger && opts.logger.error ) {"," opts.logger.error( error, path )"," }",""," }","",""," }",""," if( Instance[base] ) {",""," Object.defineProperties( Instance[base], {"," '__path': {"," 'enumerable': false,"," 'writable': true,"," 'configurable': true,"," 'value': require.resolve( path )"," },"," '__directory': {"," 'enumerable': false,"," 'configurable': true,"," 'writable': true,"," 'value': require( 'path' ).dirname( require.resolve( path ) )"," }"," });","",""," }",""," }",""," });",""," }",""," return Instance;",""," });"," ","});",""]; |
@@ -19,3 +19,2 @@ /** | ||
ar.should.be.a( 'function' ); | ||
ar.should.have.property( 'utility' ); | ||
@@ -44,2 +43,10 @@ // Inherited Abstract methods | ||
}, | ||
'realpath() joins and resolves': function() { | ||
// should resolve to /static/assets | ||
require( '../' ).realpath( 'static' ); | ||
require( '../' ).realpath( 'static', 'assets' ); | ||
} | ||
@@ -46,0 +53,0 @@ |
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
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 2 instances 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
142310
35
1861
5
6
15
+ Addedinclude-all@*
+ Addedwatch@*
+ Added@sailshq/lodash@3.10.6(transitive)
+ Addedexec-sh@0.2.2(transitive)
+ Addedinclude-all@4.0.3(transitive)
+ Addedmerge@1.2.1(transitive)
+ Addedmerge-dictionaries@0.0.3(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedwatch@1.0.2(transitive)