Switch from fs to graceful-fs

This commit is contained in:
silverwind 2014-01-23 00:43:05 +01:00
parent 65e80e5788
commit 64cc1ce056
2 changed files with 11 additions and 10 deletions

View file

@ -11,7 +11,7 @@
* ~ Ryan McGrath (ryan [at] venodesigns.net) * ~ Ryan McGrath (ryan [at] venodesigns.net)
*/ */
var fs = require("fs"), var fs = require("graceful-fs"),
_path = require("path"), _path = require("path"),
isWindows = !!process.platform.match(/^win/); isWindows = !!process.platform.match(/^win/);
@ -206,11 +206,11 @@ function isFileIncluded(opts, dir, filename) {
var filter = opts.filter; var filter = opts.filter;
if (!opts.whitelist) { if (!opts.whitelist) {
// if !opts.whitelist is false every file or directory // if !opts.whitelist is false every file or directory
// which does match opts.filter will be ignored // which does match opts.filter will be ignored
return isMatch(filter) ? false : true; return isMatch(filter) ? false : true;
} else { } else {
// if opts.whitelist is true every file or directory // if opts.whitelist is true every file or directory
// which doesn't match opts.filter will be ignored // which doesn't match opts.filter will be ignored
return !isMatch(filter) ? false : true; return !isMatch(filter) ? false : true;
} }
@ -231,7 +231,7 @@ exports.copyDirSyncRecursive = function(sourceDir, newDirLocation, opts) {
opts = opts || {}; opts = opts || {};
try { try {
if(fs.statSync(newDirLocation).isDirectory()) { if(fs.statSync(newDirLocation).isDirectory()) {
if(opts.forceDelete) { if(opts.forceDelete) {
exports.rmdirSyncRecursive(newDirLocation); exports.rmdirSyncRecursive(newDirLocation);
} else { } else {
@ -261,7 +261,7 @@ exports.copyDirSyncRecursive = function(sourceDir, newDirLocation, opts) {
continue; continue;
} }
} }
if (opts.excludeHiddenUnix && /^\./.test(files[i])) continue; if (opts.excludeHiddenUnix && /^\./.test(files[i])) continue;
} }
@ -365,12 +365,12 @@ exports.rmdirRecursive = function rmdirRecursive(dir, failSilent, clbk){
clbk = function(err) {}; clbk = function(err) {};
fs.readdir(dir, function(err, files) { fs.readdir(dir, function(err, files) {
if(err && typeof failSilent === 'boolean' && !failSilent) if(err && typeof failSilent === 'boolean' && !failSilent)
return clbk(err); return clbk(err);
if(typeof failSilent === 'function') if(typeof failSilent === 'function')
clbk = failSilent; clbk = failSilent;
(function rmFile(err){ (function rmFile(err){
if (err) return clbk(err); if (err) return clbk(err);

View file

@ -18,6 +18,7 @@
}, },
"dependencies": { "dependencies": {
"graceful-fs": "~2.0.1"
}, },
"devDependencies": { "devDependencies": {
@ -26,10 +27,10 @@
"main": "./lib/wrench", "main": "./lib/wrench",
"engines": { "engines": {
"node": ">=0.1.97" "node": ">=0.4.0"
}, },
"scripts": { "test": "nodeunit tests/runner.js" }, "scripts": { "test": "nodeunit tests/runner.js" },
"licenses": [{ "licenses": [{