Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@beyonk/load-all

Package Overview
Dependencies
Maintainers
4
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@beyonk/load-all - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

.idea/$CACHE_FILE$

4

index.js

@@ -36,5 +36,5 @@ 'use strict'

return loadFiles(dir, (curr, absolutePath) => {
const exported = proxy.load(absolutePath)
return { ...curr, ...modifier(exported) }
const exported = require(absolutePath)
return { ...curr, ...modifier(exported, curr) }
}, kind, {})
}
'use strict'
const fs = require('fs')
const { join, basename } = require('path')
const { join } = require('path')
const { fs: memfs, vol } = require('memfs')

@@ -10,2 +10,4 @@ const sinon = require('sinon')

const proxy = require('./require-proxy')
const { patchRequire } = require('fs-monkey')
const loadAll = require('.')

@@ -20,3 +22,3 @@

if (usesRequire) {
stub(proxy, 'load').callsFake(arg => ({ [basename(arg)]: 'loaded!' }))
patchRequire(vol)
} else {

@@ -31,3 +33,3 @@ stub(proxy, 'load').callsFake(arg => [ `loaded ${arg}!` ])

fs.statSync.restore()
proxy.load.restore()
proxy.load.restore && proxy.load.restore()
}

@@ -117,5 +119,5 @@

root = createFilesystem({
'./dir1/index.js': '',
'./dir2/index.js': '',
'./dir3/index.js': '',
'./dir1/index.js': 'module.exports={ dir1: "loaded!" }',
'./dir2/index.js': 'module.exports={ dir2: "loaded!" }',
'./dir3/index.js': 'module.exports={ dir3: "loaded!" }',
}, true)

@@ -140,11 +142,2 @@ })

context('with modifier', () => {
let root
beforeEach(() => {
root = createFilesystem({
'./dir1/index.js': '',
'./dir2/index.js': '',
'./dir3/index.js': '',
}, true)
})
afterEach(() => {

@@ -155,2 +148,8 @@ destroyFilesystem()

it('sees dirs', () => {
const root = createFilesystem({
'./dir1/index.js': 'module.exports={ dir1: "loaded!" }',
'./dir2/index.js': 'module.exports={ dir2: "loaded!" }',
'./dir3/index.js': 'module.exports={ dir3: "loaded!" }',
}, true)
expect(

@@ -167,2 +166,21 @@ loadAll.exportDir(root, undefined, m => {

})
it('is passed previous', () => {
const root = createFilesystem({
'./dir1/index.js': 'module.exports={ dir1: "loaded!", sameKey: 1 }',
'./dir2/index.js': 'module.exports={ dir2: "loaded!", sameKey: 1 }',
'./dir3/index.js': 'module.exports={ dir3: "loaded!", sameKey: 1 }',
}, true)
expect(
loadAll.exportDir(root, undefined, (m, prev) => {
return { ...m, sameKey: m.sameKey + (prev.sameKey || 0) }
})
).to.equal({
dir1: 'loaded!',
dir2: 'loaded!',
dir3: 'loaded!',
sameKey: 3
})
})
})

@@ -174,5 +192,5 @@

root = createFilesystem({
'./dir1/index.js': '',
'./file2.js': '',
'./dir3/index.js': '',
'./dir1/index.js': 'module.exports={ dir1: "loaded!" }',
'./file2.js': 'module.exports={ dir2: "loaded!" }',
'./dir3/index.js': 'module.exports={ dir3: "loaded!" }',
}, true)

@@ -179,0 +197,0 @@ })

{
"name": "@beyonk/load-all",
"version": "0.1.0",
"version": "0.2.0",
"description": "Loads all files from within a directory",

@@ -34,2 +34,3 @@ "main": "index.js",

"code": "^5.2.4",
"fs-monkey": "^1.0.1",
"memfs": "^2.14.2",

@@ -36,0 +37,0 @@ "mocha": "^5.2.0",

@@ -46,3 +46,3 @@ <p align="center">

// }
``
```

@@ -49,0 +49,0 @@ ### includeDir

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