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

mock-fs

Package Overview
Dependencies
Maintainers
1
Versions
86
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 1.1.0 to 1.2.0

35

lib/filesystem.js

@@ -0,1 +1,2 @@

var os = require('os');
var path = require('path');

@@ -27,2 +28,23 @@

var root = new Directory();
// populate with default directories
var defaults = [os.tmpdir && os.tmpdir() || os.tmpDir(), process.cwd()];
defaults.forEach(function(dir) {
var parts = getPathParts(dir);
var directory = root;
var i, ii, name, candidate;
for (i = 0, ii = parts.length; i < ii; ++i) {
name = parts[i];
candidate = directory.getItem(name);
if (!candidate) {
directory = directory.addItem(name, new Directory());
} else if (candidate instanceof Directory) {
directory = candidate;
} else {
throw new Error('Failed to create directory: ' + dir);
}
}
});
/**

@@ -32,3 +54,3 @@ * Root directory.

*/
this._root = new Directory();
this._root = root;

@@ -79,3 +101,12 @@ }

}
directory.addItem(name, item);
/**
* Special exception for redundant adding of empty directories.
*/
if (item instanceof Directory &&
item.list().length === 0 &&
directory.getItem(name) instanceof Directory) {
// pass
} else {
directory.addItem(name, item);
}
}

@@ -82,0 +113,0 @@

2

package.json
{
"name": "mock-fs",
"description": "Mock fs implementation for testing",
"version": "1.1.0",
"version": "1.2.0",
"main": "lib/index.js",

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

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