Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Create a require()
function from any file-system.
index
and implicit extensions js
and json
__dirname
& __filename
fs
within fsRequirefs-require://
protocolUsing fs-require with memfs is a great combination for writing tests that interact with the file-system.
Testing functionality that interacts with the file-system can be brittle because they expect a clean slate and can also be dangerous if the path is wrong. Creating a virtual file-system with memfs
and testing its contents with fsRequire
makes it secure and fast!
import { Volume } from 'memfs'
import { createFsRequire } from 'fs-require'
// Create a virtual fs from JSON
const virtualFs = Volume.fromJSON({
'/hello-world.js': `
module.exports = function () {
return 'Hello world!'
}
`
})
// Create fsRequire
const fsRequire = createFsRequire(virtualFs)
// Import virtual module
const helloWorld = fsRequire('/hello-world')
console.log(helloWorld()) // Hello world!
Returns a require(modulePath)
function that resolves from the file-system passed in.
Type: FileSystem
Required
The file-system to resolve requires from.
Type: boolean | FileSystem
Code executed the virtual file-system may require('fs')
and this may either pose as a security concern or yield inconsistent results as the virtual file won't not accessible through the actual fs
module.
By default require('fs')
is shimmed to the file-system passed into createFsRequire
.
To disable this behavior and resolve to the real fs
module, set this to true
.
You can also pass in a different file-system too.
Case sensitivity in paths is a file-system concern so it would depend on the fs
passed in. For example, macOS (native fs) is case insensitive. memfs is case sensitive.
FAQs
Create a require() function from any file-system
The npm package fs-require receives a total of 6,462 weekly downloads. As such, fs-require popularity was classified as popular.
We found that fs-require demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.