mirror of
https://github.com/RustyRaptor/brackets.git
synced 2026-12-05 00:45:21 -07:00
64 lines
8.5 KiB
JSON
Executable File
64 lines
8.5 KiB
JSON
Executable File
{
|
|
"name": "fs-extra",
|
|
"version": "0.5.0",
|
|
"description": "fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as mkdir -p, cp -r, and rm -rf.",
|
|
"homepage": [
|
|
"https://github.com/jprichardson/node-fs-extra"
|
|
],
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "https://github.com/jprichardson/node-fs-extra"
|
|
},
|
|
"keywords": [
|
|
"fs",
|
|
"file",
|
|
"file system",
|
|
"copy",
|
|
"directory",
|
|
"extra",
|
|
"mkdirp",
|
|
"mkdir",
|
|
"mkdirs",
|
|
"recursive",
|
|
"json",
|
|
"read",
|
|
"write",
|
|
"extra",
|
|
"delete",
|
|
"remove",
|
|
"touch",
|
|
"create",
|
|
"text",
|
|
"output"
|
|
],
|
|
"author": {
|
|
"name": "JP Richardson",
|
|
"email": "jprichardson@gmail.com"
|
|
},
|
|
"licenses": [
|
|
{
|
|
"type": "MIT",
|
|
"url": "http://github.com/jprichardson/node-fs-extra/raw/master/LICENSE"
|
|
}
|
|
],
|
|
"dependencies": {
|
|
"ncp": "0.2.x",
|
|
"mkdirp": "0.3.x",
|
|
"jsonfile": "0.0.x",
|
|
"rimraf": "~2.1.2"
|
|
},
|
|
"devDependencies": {
|
|
"mocha": "*",
|
|
"path-extra": "0.0.x",
|
|
"testutil": "~0.4.0"
|
|
},
|
|
"main": "./lib/index",
|
|
"scripts": {
|
|
"test": "mocha test"
|
|
},
|
|
"readme": "[](http://travis-ci.org/jprichardson/node-fs-extra)\n\nNode.js: fs-extra\n=================\n\nThis module adds a few extra file system methods that aren't included in the native `fs` module. It is a drop in replacement for `fs`.\n\n\n\nWhy?\n----\n\nI got tired of including `mkdirp`, `rimraf`, and `cp -r` in most of my projects. \n\n\n\n\nInstallation\n------------\n\n npm install fs-extra\n\n\n\nUsage\n-----\n\n```javascript\nvar fs = require('fs-extra');\n```\n\n\n\nMethods\n-------\n\n**NOTE:** You can still use the native Node.js methods. They are copied over to `fs-extra`.\n\n\n### copy(src, dest, callback)\n\nCopy a file or directory. The directory can have contents. Like `cp -r`. There isn't a synchronous version implemented yet.\n\nSync: (none)\n\n\nExamples:\n\n```javascript\nvar fs = require('fs-extra');\n\nfs.copy('/tmp/myfile', '/tmp/mynewfile', function(err){\n if (err) {\n console.error(err);\n }\n else {\n console.log(\"success!\")\n }\n}); //copies file\n\nfs.copy('/tmp/mydir', '/tmp/mynewdir', function(err){\n if (err) {\n console.error(err);\n }\n else {\n console.log(\"success!\")\n }\n}); //copies directory, even if it has subdirectories or files\n```\n\n\n### createFile(file, callback) \n\nCreates a file. If the file that is requested to be created is in directories that do not exist, these directories are created. If the file already exists, it is **NOT MODIFIED**.\n\nSync: `createFileSync()`\n\n\nExample:\n\n```javascript\nvar fs = require('fs-extra')\n , file = '/tmp/this/path/does/not/exist/file.txt'\n\nfs.createFile(file, function(err) {\n console.log(err); //null\n\n //file has now been created, including the directory it is to be placed in\n})\n```\n\n\n### exists() / existsSync()\n\nThese methods are actually from `path` in v0.6. But in Node v0.8 they are moved from `path` to `fs`. So you can use this module to help make your modules v0.6 and v0.8 compatible.\n\n\n\n### mkdirs(dir, callback) \n\nCreates a directory. If the parent hierarchy doesn't exist, it's created. Like `mkdir -p`.\n\nAlias: `mkdirp()`\n\nSync: `mkdirsSync()` / `mkdirpSync()`\n\n\nExamples:\n\n```javascript\nvar fs = require('fs-extra');\n\nfs.mkdirs('/tmp/some/long/path/that/prob/doesnt/exist', function(err){\n if (err) {\n console.error(err);\n }\n else {\n console.log(\"success!\")\n }\n});\n\nfs.mkdirsSync('/tmp/another/path');\n```\n\n\n### outputFile(file, data, callback)\n\nAlmost the same as `writeFile`, except that if the directory does not exist, it's created.\n\nSync: `outputFileSync()`\n\n\nExample:\n\n```javascript\nvar fs = require('fs-extra')\n , file = '/tmp/this/path/does/not/exist/file.txt'\n\nfs.outputFile(file, 'hello!' function(err) {\n console.log(err); //null\n\n fs.readFile(file, 'utf8', function(err, data) {\n console.log(data); //hello!\n })\n})\n```\n\n\n### readJson(file, callback) \n\nReads a JSON file and then parses it into an object.\n\nAlias: `readJSON()`\n\nSync: `readJsonSync()`, `readJSONSync()`\n\n\nExample:\n\n```javascript\nvar fs = require('fs-extra');\n\nfs.readJson('./package.json', function(err, packageObj) {\n console.log(packageObj.version); //0.1.3\n});\n```\n\n\n### remove(dir, callback)\n\nRemoves a file or directory. The directory can have contents. Like `rm -rf`.\n\nAlias: `delete()`\n\nSync: `removeSync()` / `deleteSync()`\n\n\nExamples:\n\n```javascript\nvar fs = require('fs-extra');\n\nfs.remove('/tmp/myfile', function(err){\n if (err) {\n console.error(err);\n }\n else {\n console.log(\"success!\")\n }\n});\n\nfs.removeSync('/home/jprichardson'); //I just deleted my entire HOME directory. \n```\n\n\n\n### writeJson(file, object, callback) \n\nWrites an object to a JSON file.\n\nAlias: `writeJSON()`\n\nSync: `writeJsonSync()`, `writeJSONSync()`\n\nExample:\n\n```javascript\nvar fs = require('fs-extra');\nfs.writeJson('./package.json', {name: 'fs-extra'}, function(err){\n console.log(err);\n});\n```\n\n\n\nRoadmap \n-------\n\nThis contains items that I'm considering doing. I'd love community feedback.\n\n* File system walker. I really like this one: https://github.com/daaku/nodejs-walker\n* File/directory tree watcher. There are quite a few.\n* Method to move files.\n* Copy sync.\n* Thinking about moving `rimraf`, `ncp`, and `mkdirps` code into this library. I'd like fs-extra to be a stable library that module authors\ncan depend upon. A bunch of other dependencies kinda sucks for modules/libraries.\n* Change documentation to use the `fse` prefix instead of `fs`. This may encourage people to start using `fse` as a prefix and hence make their code clearer that they're not using the native `fs`. I'm very undecided on this one since `fs-extra` is a drop in replacement for the native `fs`.\n\n\n\nNaming\n------\n\nI put a lot of thought into the naming of these function. Inspired by @coolaj86's request. So he deserves much of the credit for raising the issue. See discussion(s) here:\n\n* https://github.com/jprichardson/node-fs-extra/issues/2\n* https://github.com/flatiron/utile/issues/11\n* https://github.com/ryanmcgrath/wrench-js/issues/29\n* https://github.com/substack/node-mkdirp/issues/17\n\nFirst, I believe that in as many cases as possible, the [Node.js naming schemes](http://nodejs.org/api/fs.html) should be chosen. However, there are problems with the Node.js own naming schemes.\n\nFor example, `fs.readFile()` and `fs.readdir()`: the **F** is capitalized in *File* and the **d** is not capitalized in *dir*. Perhaps a bit pedantic, but they should still be consistent. Also, Node.js has chosen a lot of POSIX naming schemes, which I believe is great. See: `fs.mkdir()`, `fs.rmdir()`, `fs.chown()`, etc.\n\nWe have a dilemma though. How do you consistently name methods that perform the following POSIX commands: `cp`, `cp -r`, `mkdir -p`, and `rm -rf`?\n\nMy perspective: when in doubt, err on the side of simplicity. Consider that for a moment. A directory is just a hierarchical grouping of directories and files. So when you want to copy it or remove it, in most cases you'll want to copy or remove all of its contents. When you want to create a directory, if the directory that it's suppose to be contained in does not exist, then in most cases you'll want to create that too. \n\nSo, if you want to remove a file or a directory regardless of whether it has contents, just call `fs.remove(path)` or its alias `fs.delete(path)`. If you want to copy a file or a directory whether it has contents, just call `fs.copy(source, destination)`. If you want to create a directory regardless of whether its parent directories exist, just call `fs.mkdirs(path)` or `fs.mkdirp(path)`. \n\n\n\nAuthor\n------\n\n`node-fs-extra` was written by [JP Richardson][aboutjp]. You should follow him on Twitter [@jprichardson][twitter]. Also read his coding blog [Procbits][procbits]. If you write software with others, you should checkout [Gitpilot][gitpilot] to make collaboration with Git simple.\n\n\n\n\nLicense\n-------\n\n\nLicensed under MIT\n\nCopyright (c) 2011-2013 JP Richardson\n\n[1]: http://nodejs.org/docs/latest/api/fs.html \n\n\n[jsonfile]: https://github.com/jprichardson/node-jsonfile\n\n\n[aboutjp]: http://about.me/jprichardson\n[twitter]: http://twitter.com/jprichardson\n[procbits]: http://procbits.com\n[gitpilot]: http://gitpilot.com\n\n\n\n",
|
|
"readmeFilename": "README.md",
|
|
"_id": "fs-extra@0.5.0",
|
|
"_from": "fs-extra@0.5.x"
|
|
}
|