git-node-fs
Advanced tools
Comparing version 0.1.0 to 1.0.0
@@ -12,2 +12,3 @@ "use strict"; | ||
fs.readDir = readDir; | ||
fs.rename = rename; | ||
@@ -20,10 +21,6 @@ // Reads all bytes for given path. | ||
if (err) { | ||
if (err.code === "ENOENT") { | ||
callback(); | ||
} else { | ||
callback(err); | ||
} | ||
} else { | ||
callback(null, binary); | ||
if (err.code === "ENOENT") return callback(); | ||
return callback(err); | ||
} | ||
return callback(null, binary); | ||
}); | ||
@@ -46,14 +43,8 @@ } | ||
var chunk = stream.read(); | ||
if (chunk === null) { | ||
callback(null, Buffer.concat(chunks)); | ||
} else { | ||
chunks.push(chunk); | ||
} | ||
if (chunk === null) return callback(null, Buffer.concat(chunks)); | ||
return chunks.push(chunk); | ||
}); | ||
stream.on("error", function (err) { | ||
if (err.code === "ENOENT") { | ||
callback(); | ||
} else { | ||
callback(err); | ||
} | ||
if (err.code === "ENOENT") return callback(); | ||
return callback(err); | ||
}); | ||
@@ -68,7 +59,4 @@ } | ||
if (err) { | ||
if (err.code === "EACCES") { | ||
callback(); | ||
} else { | ||
callback(err); | ||
} | ||
if (err.code === "EACCES") return callback(); | ||
return callback(err); | ||
} | ||
@@ -90,11 +78,8 @@ var buffer = new Buffer(4096); | ||
function onread(err, bytesRead) { | ||
if (err) { | ||
callback(err); | ||
} | ||
if (err) return callback(err); | ||
length += bytesRead; | ||
if (bytesRead === 0) { | ||
callback(null, buffer.slice(0, buffer.length + end)); | ||
} else { | ||
read(); | ||
return callback(null, buffer.slice(0, buffer.length + end)); | ||
} | ||
read(); | ||
} | ||
@@ -115,10 +100,22 @@ | ||
mkdirp(nodePath.dirname(path), function (err) { | ||
if (err) { | ||
callback(err); | ||
} else { | ||
nodeFs.writeFile(path, binary, callback); | ||
} | ||
if (err) return callback(err); | ||
nodeFs.writeFile(path, binary, callback); | ||
}); | ||
} | ||
// Renames the given file. | ||
// Creates all necessary parent directories. | ||
// => undefined | ||
function rename(oldPath, newPath, callback) { | ||
var oldBase = nodePath.dirname(oldPath); | ||
var newBase = nodePath.dirname(newPath); | ||
if (oldBase === newBase) { | ||
return nodeFs.rename(oldPath, newPath, callback); | ||
} | ||
mkdirp(nodePath.dirname(path), function (err) { | ||
if (err) return callback(err); | ||
nodeFs.rename(oldPath, newPath, callback); | ||
}); | ||
} | ||
// Reads all entry names for a given path. | ||
@@ -131,10 +128,6 @@ // All names are relative to the directory itself, not fully qualified paths. | ||
if (err) { | ||
if (err.code === "ENOENT") { | ||
callback(); | ||
} else { | ||
callback(err); | ||
} | ||
} else { | ||
callback(null, names); | ||
if (err.code === "ENOENT") return callback(); | ||
return callback(err); | ||
} | ||
return callback(null, names); | ||
}); | ||
@@ -151,3 +144,3 @@ } | ||
if (err && err.code !== "EEXIST") return callback(err); | ||
callback(); | ||
return callback(); | ||
}); | ||
@@ -154,0 +147,0 @@ }); |
@@ -8,3 +8,3 @@ { | ||
], | ||
"version": "0.1.0", | ||
"version": "1.0.0", | ||
"main": "lib/node-fs.js", | ||
@@ -11,0 +11,0 @@ "scripts": { |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
7834
0
179