New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mock-fs

Package Overview
Dependencies
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mock-fs - npm Package Compare versions

Comparing version 3.10.0 to 3.11.0

7

changelog.md
# Change Log
## 3.11.0
* Make `require()` calls use the real filesystem ([#139][#139]).
* Reduce the manual `fs` module patching ([#140][#140]).
## 3.10.0

@@ -134,1 +139,3 @@

[#138]: https://github.com/tschaub/mock-fs/pull/138
[#139]: https://github.com/tschaub/mock-fs/pull/139
[#140]: https://github.com/tschaub/mock-fs/pull/140

8

lib/binding.js

@@ -32,3 +32,5 @@ 'use strict';

// Unpack callback from FSReqWrap
callback = callback.oncomplete || callback;
if (callback.oncomplete) {
callback = callback.oncomplete.bind(callback);
}
process.nextTick(function() {

@@ -524,3 +526,5 @@ if (val === undefined) {

if (callback) {
callback = callback.oncomplete || callback;
if (callback.oncomplete) {
callback = callback.oncomplete.bind(callback);
}
wrapper = function(err, written, returned) {

@@ -527,0 +531,0 @@ callback(err, written, returned && string);

@@ -53,3 +53,12 @@ 'use strict';

if (!descriptor || descriptor && descriptor.writable) {
realFs[name] = mockFs[name];
realFs[name] = (function(mockFunction, realFunction) {
return function() {
var stack = new Error().stack;
if (stack.indexOf('at Module.require (module') >= 0) {
return realFunction.apply(realFs, arguments);
} else {
return mockFunction.apply(realFs, arguments);
}
};
}(mockFs[name], realFs[name]));
}

@@ -56,0 +65,0 @@ }

@@ -252,3 +252,3 @@ // Maintainers, keep in mind that ES1-style octal literals (`0666`) are not

req.context = context;
req.oncomplete = readFileAfterOpen.bind(req);
req.oncomplete = readFileAfterOpen;

@@ -298,3 +298,3 @@ if (context.isUserFd) {

var req = new FSReqWrap();
req.oncomplete = readFileAfterRead.bind(req);
req.oncomplete = readFileAfterRead;
req.context = this;

@@ -307,3 +307,3 @@

var req = new FSReqWrap();
req.oncomplete = readFileAfterClose.bind(req);
req.oncomplete = readFileAfterClose;
req.context = this;

@@ -333,3 +333,3 @@ this.err = err;

var req = new FSReqWrap();
req.oncomplete = readFileAfterStat.bind(req);
req.oncomplete = readFileAfterStat;
req.context = context;

@@ -336,0 +336,0 @@ binding.fstat(fd, req);

{
"name": "mock-fs",
"description": "A configurable mock file system. You know, for testing.",
"version": "3.10.0",
"version": "3.11.0",
"main": "lib/index.js",

@@ -6,0 +6,0 @@ "homepage": "https://github.com/tschaub/mock-fs",

@@ -1,24 +0,6 @@

var mock = require('./lib');
var fs = require('fs');
mock({
dir: {
link: mock.symlink({
path: 'foo'
}),
foo: {
bar: 'content'
}
}
});
mock({'test.json': JSON.stringify({name: 'bam'})}, {mockRequire: true});
var pkg = require('./test.json');
fs.readdir('dir', function(err, items) {
if (err) {
process.stderr.write(`${err.stack}\n`);
process.exit(1);
} else {
process.stdout.write(`items: ${items}\n`);
process.exit(0);
}
});
console.log(pkg.name);

Sorry, the diff of this file is too big to display

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