Socket
Socket
Sign inDemoInstall

moder

Package Overview
Dependencies
2
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.1 to 1.3.2

test/modules/case3/app3/.gitkeep

42

index.js

@@ -41,19 +41,35 @@ var fs = require('fs')

fs.readdirSync(dirname).forEach(function(filename) {
// filter index and dotfiles
// custom filter
if (options.filter(filename)) {
return
}
var stat = fs.statSync(path.join(dirname, filename))
var isModule = stat.isFile() && path.extname(filename) === '.js' && filename !== 'index.js' && filename[0] !== '.'
if (stat.isDirectory()) {
// filter directory without index.js
try {
fs.accessSync(path.join(dirname, filename, 'index.js'))
} catch (err) {
return
}
} else {
// filter not .js or temporary files
var isModule = stat.isFile() && path.extname(filename) === '.js' && filename !== 'index.js' && filename[0] !== '.'
if (!isModule) {
return
}
}
var moduleName = path.basename(filename, path.extname(filename))
var modulePath = path.join(dirname, moduleName)
var exportName = options.naming(moduleName)
if ((stat.isDirectory() || isModule) && !options.filter(filename)) {
// lazy load
if (options.lazy) {
Object.defineProperty(modules, exportName, {
get: function() {
return options.init(require(modulePath))
}
})
} else {
modules[exportName] = options.init(require(modulePath))
}
// lazy load
if (options.lazy) {
Object.defineProperty(modules, exportName, {
get: function() {
return options.init(require(modulePath))
}
})
} else {
modules[exportName] = options.init(require(modulePath))
}

@@ -60,0 +76,0 @@ })

{
"name": "moder",
"version": "1.3.1",
"version": "1.3.2",
"description": "Module loader",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -33,2 +33,3 @@ var path = require('path'),

assert.equal(case3.app2, 'app2')
assert.equal(case3.app3, undefined)
})

@@ -35,0 +36,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc