diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..c69ebf7 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "fs-extra"] + path = fs-extra + url = git://github.com/jprichardson/node-fs-extra.git +[submodule "wrench"] + path = wrench + url = git://github.com/ryanmcgrath/wrench-js.git diff --git a/README.md b/README.md index 41d2923..ba84f01 100644 --- a/README.md +++ b/README.md @@ -1,138 +1,13 @@ -fs.extra -=== +A temporary holding space for fs-extra, fs.extra, wrench, and utile until we figure out how to merge them together. -Adds `copy`, `copyRecursive`, `mkdirp`, `move`, `walk`, and `rmrf` to Node.JS' `fs`. +Included methods: -Install with `npm install -S fs.extra` + * rmraf + * mkdirp + * walk + * copy (recursive) + * delete (recursive) + * remove (recursive) + * exists (shim) - // this will have all of the normal fs methods - var fs = require('fs.extra'); - -fs.copy -=== - -Creates an `fs.readStream` and `fs.writeStream` and uses `util.pump` to efficiently copy. - - fs.copy('foo.txt', 'bar.txt', function (err) { - if (err) { - throw err; - } - - console.log("Copied 'foo.txt' to 'bar.txt'); - }); - -fs.copyRecursive -=== - -Basically a local `rsync`, uses `fs.copy` to recursively copy files and folders (with correct permissions). - - fs.copyRecursive('./foo', './bar', function (err) { - if (err) { - throw err; - } - - console.log("Copied './foo' to './bar'); - }); - -fs.mkdirRecursive -=== - -Included from - - // fs.mkdirp(path, mode=(0777 & (~process.umask())), cb); - - fs.mkdirp('/tmp/foo/bar/baz', function (err) { - if (err) { - console.error(err); - } else { - console.log('pow!') - } - }); - -fs.mkdirRecursiveSync -=== - -Included from - - // fs.mkdirpSync(path, mode=(0777 & (~process.umask()))); - - try { - fs.mkdirpSync('/tmp/foo/bar/baz'); - } catch(e) { - throw e; - } - -fs.move -=== - -Attempts `fs.rename`, then tries `fs.copy` + `fs.unlink` before failing. - - fs.move('foo.txt', 'bar.txt', function (err) { - if (err) { - throw err; - } - - console.log("Moved 'foo.txt' to 'bar.txt'); - }); - -fs.rmRecursive -=== - -Included from - -Recursively deletes a directory (like `rm -rf`) - - // fs.rmrf(dir, callback); - - fs.rmrf('/choose/me/carefully/', function (err) { - if (err) { - console.error(err); - } - }); - -fs.rmRecursiveSync -=== - -Included from - -Recursively deletes a directory (like `rm -rf`) - - // fs.rmrfSync(dir); - - fs.rmrfSync('/choose/me/carefully/'); - -fs.walk -=== - -See - - var walker = fs.walk(dir) - ; - - // file, files, directory, directories - walker.on("file", function (root, stat, next) { - var filepath = path.join(root, stat.name) - ; - - console.log(filepath); - }); - -Aliases and Backwards Compatibility -=== - -For the sake of backwards compatability, you can call the recursive functions with their names as such - - fs.remove <- fs.rmRecursive <- fs.rmrf - fs.removeSync <- fs.rmRecursiveSync <- fs.rmrfSync - fs.mkdirRecursive <- fs.mkdirp - fs.mkdirRecursiveSync <- fs.mkdirpSync - -License -=== - -Copyright AJ ONeal 2011-2012 - -This project is available under the MIT and Apache v2 licenses. - - * http://www.opensource.org/licenses/mit-license.php - * http://www.apache.org/licenses/LICENSE-2.0.html +Some of these are duplicated, we'll figure it out eventually. diff --git a/fs-extra b/fs-extra new file mode 160000 index 0000000..b1e6c3d --- /dev/null +++ b/fs-extra @@ -0,0 +1 @@ +Subproject commit b1e6c3d04436807db49e1871361be8b6f6d6a43c diff --git a/LICENSE.APACHE2 b/fs.extra/LICENSE.APACHE2 similarity index 100% rename from LICENSE.APACHE2 rename to fs.extra/LICENSE.APACHE2 diff --git a/LICENSE.MIT b/fs.extra/LICENSE.MIT similarity index 100% rename from LICENSE.MIT rename to fs.extra/LICENSE.MIT diff --git a/fs.extra/README.md b/fs.extra/README.md new file mode 100644 index 0000000..41d2923 --- /dev/null +++ b/fs.extra/README.md @@ -0,0 +1,138 @@ +fs.extra +=== + +Adds `copy`, `copyRecursive`, `mkdirp`, `move`, `walk`, and `rmrf` to Node.JS' `fs`. + +Install with `npm install -S fs.extra` + + // this will have all of the normal fs methods + var fs = require('fs.extra'); + +fs.copy +=== + +Creates an `fs.readStream` and `fs.writeStream` and uses `util.pump` to efficiently copy. + + fs.copy('foo.txt', 'bar.txt', function (err) { + if (err) { + throw err; + } + + console.log("Copied 'foo.txt' to 'bar.txt'); + }); + +fs.copyRecursive +=== + +Basically a local `rsync`, uses `fs.copy` to recursively copy files and folders (with correct permissions). + + fs.copyRecursive('./foo', './bar', function (err) { + if (err) { + throw err; + } + + console.log("Copied './foo' to './bar'); + }); + +fs.mkdirRecursive +=== + +Included from + + // fs.mkdirp(path, mode=(0777 & (~process.umask())), cb); + + fs.mkdirp('/tmp/foo/bar/baz', function (err) { + if (err) { + console.error(err); + } else { + console.log('pow!') + } + }); + +fs.mkdirRecursiveSync +=== + +Included from + + // fs.mkdirpSync(path, mode=(0777 & (~process.umask()))); + + try { + fs.mkdirpSync('/tmp/foo/bar/baz'); + } catch(e) { + throw e; + } + +fs.move +=== + +Attempts `fs.rename`, then tries `fs.copy` + `fs.unlink` before failing. + + fs.move('foo.txt', 'bar.txt', function (err) { + if (err) { + throw err; + } + + console.log("Moved 'foo.txt' to 'bar.txt'); + }); + +fs.rmRecursive +=== + +Included from + +Recursively deletes a directory (like `rm -rf`) + + // fs.rmrf(dir, callback); + + fs.rmrf('/choose/me/carefully/', function (err) { + if (err) { + console.error(err); + } + }); + +fs.rmRecursiveSync +=== + +Included from + +Recursively deletes a directory (like `rm -rf`) + + // fs.rmrfSync(dir); + + fs.rmrfSync('/choose/me/carefully/'); + +fs.walk +=== + +See + + var walker = fs.walk(dir) + ; + + // file, files, directory, directories + walker.on("file", function (root, stat, next) { + var filepath = path.join(root, stat.name) + ; + + console.log(filepath); + }); + +Aliases and Backwards Compatibility +=== + +For the sake of backwards compatability, you can call the recursive functions with their names as such + + fs.remove <- fs.rmRecursive <- fs.rmrf + fs.removeSync <- fs.rmRecursiveSync <- fs.rmrfSync + fs.mkdirRecursive <- fs.mkdirp + fs.mkdirRecursiveSync <- fs.mkdirpSync + +License +=== + +Copyright AJ ONeal 2011-2012 + +This project is available under the MIT and Apache v2 licenses. + + * http://www.opensource.org/licenses/mit-license.php + * http://www.apache.org/licenses/LICENSE-2.0.html diff --git a/fs.copy-recursive.js b/fs.extra/fs.copy-recursive.js similarity index 100% rename from fs.copy-recursive.js rename to fs.extra/fs.copy-recursive.js diff --git a/fs.copy.js b/fs.extra/fs.copy.js similarity index 100% rename from fs.copy.js rename to fs.extra/fs.copy.js diff --git a/fs.extra.js b/fs.extra/fs.extra.js similarity index 100% rename from fs.extra.js rename to fs.extra/fs.extra.js diff --git a/fs.move.js b/fs.extra/fs.move.js similarity index 100% rename from fs.move.js rename to fs.extra/fs.move.js diff --git a/package.json b/fs.extra/package.json similarity index 100% rename from package.json rename to fs.extra/package.json diff --git a/test.js b/fs.extra/test.js similarity index 100% rename from test.js rename to fs.extra/test.js diff --git a/wrench b/wrench new file mode 160000 index 0000000..d1ffccb --- /dev/null +++ b/wrench @@ -0,0 +1 @@ +Subproject commit d1ffccba60d10fa05a0d46f0547c7fbd2f54ba8b