Socket
Socket
Sign inDemoInstall

enhanced-resolve

Package Overview
Dependencies
Maintainers
1
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enhanced-resolve - npm Package Compare versions

Comparing version 0.5.8 to 0.5.9

test/memory-filesystem.js

51

lib/MemoryInputFileSystem.js

@@ -45,11 +45,22 @@ /*

function pathToArray(path) {
var nix = /^\//.test(path);
if(!nix) {
if(!/^[A-Za-z]:\\/.test(path)) throw new Error("Invalid path " + path);
path = path.replace(/\\/g, "/");
}
path = path.replace(/\/+/g, "/"); // multi slashs
path = (nix ? path.substr(1) : path).split("/");
return path;
}
function trueFn() { return true }
function falseFn() { return false }
MemoryInputFileSystem.prototype.statSync = function(path) {
path = path.split("/");
if(path[0] != "") throw new Error("Invalid path " + path.join("/"));
MemoryInputFileSystem.prototype.statSync = function(_path) {
var path = pathToArray(_path);
var current = this.data;
for(var i = 1; i < path.length - 1; i++) {
for(var i = 0; i < path.length - 1; i++) {
if(!isDir(current[path[i]]))
throw new Error("Path doesn't exists " + path.join("/"));
throw new Error("Path doesn't exists " + _path);
current = current[path[i]];

@@ -78,12 +89,11 @@ }

} else
throw new Error("Path doesn't exists " + path.join("/"));
throw new Error("Path doesn't exists " + _path);
};
MemoryInputFileSystem.prototype.readFileSync = function(path) {
path = path.split("/");
if(path[0] != "") throw new Error("Invalid path " + path.join("/"));
MemoryInputFileSystem.prototype.readFileSync = function(_path) {
var path = pathToArray(_path);
var current = this.data;
for(var i = 1; i < path.length - 1; i++) {
for(var i = 0; i < path.length - 1; i++) {
if(!isDir(current[path[i]]))
throw new Error("Path doesn't exists " + path.join("/"));
throw new Error("Path doesn't exists " + _path);
current = current[path[i]];

@@ -93,5 +103,5 @@ }

if(isDir(current[path[i]]))
throw new Error("Cannot readFile on directory " + path.join("/"));
throw new Error("Cannot readFile on directory " + _path);
else
throw new Error("File doesn't exists " + path.join("/"));
throw new Error("File doesn't exists " + _path);
}

@@ -101,9 +111,8 @@ return current[path[i]];

MemoryInputFileSystem.prototype.readdirSync = function(path) {
path = path.split("/");
if(path[0] != "") throw new Error("Invalid path " + path.join("/"));
MemoryInputFileSystem.prototype.readdirSync = function(_path) {
var path = pathToArray(_path);
var current = this.data;
for(var i = 1; i < path.length - 1; i++) {
for(var i = 0; i < path.length - 1; i++) {
if(!isDir(current[path[i]]))
throw new Error("Path doesn't exists " + path.join("/"));
throw new Error("Path doesn't exists " + _path);
current = current[path[i]];

@@ -113,7 +122,7 @@ }

if(isFile(current[path[i]]))
throw new Error("Cannot readFile on file " + path.join("/"));
throw new Error("Cannot readFile on file " + _path);
else
throw new Error("File doesn't exists " + path.join("/"));
throw new Error("File doesn't exists " + _path);
}
return Object.keys(current[path[i]]);
return Object.keys(current[path[i]]).filter(Boolean);
};
{
"name": "enhanced-resolve",
"version": "0.5.8",
"version": "0.5.9",
"author": "Tobias Koppers @sokra",

@@ -5,0 +5,0 @@ "description": "Offers a async require.resolve function. It's highly configurable.",

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