enhanced-resolve
Advanced tools
Comparing version 0.5.8 to 0.5.9
@@ -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.", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47746
52
1329