diff --git a/CHANGELOG.md b/CHANGELOG.md index 8399dc6d..0ba446f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ * removed node 0.6 support * added node 0.10 support * upgraded to latest `ncp` and `rimraf`. -* optional `graceful-fs` support. See #17 +* optional `graceful-fs` support. Closes #17 0.5.0 / 2013-02-03 diff --git a/lib/index.js b/lib/index.js index 5d86d08a..1b9848f3 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,15 +1,21 @@ -var fs = require('fs') +var fs = null , path = require('path') , jsonFile = require('jsonfile') , fse = {}; +try { + // optional dependency + fs = require("graceful-fs") +} catch (er) { + fs = require("fs") +} + Object.keys(fs).forEach(function(key) { var func = fs[key]; if (typeof func == 'function') fse[key] = func; }); - fs = fse; // copy