{"_id":"filepath","_rev":"25-f33865a5018d43baa39812ac246dbd71","name":"filepath","description":"A cross platform utility interface for working with filesystems in Node.js.","dist-tags":{"latest":"1.1.0"},"versions":{"0.1.0":{"name":"filepath","version":"0.1.0","description":"A nice little interface for working with the filesystem in Node.js.","author":{"name":"Kris Walker","email":"kris@kixx.name","url":"http://www.kixx.name/"},"keywords":["filepath","files","directories","file","system","filesystem","path"],"repository":{"type":"git","url":"https://github.com/kixxauth/filepath.git"},"bugs":"https://github.com/kixxauth/filepath/issues","dependencies":{"iou":"0.1.0","ini":"1.1.0"},"_id":"filepath@0.1.0","dist":{"shasum":"5fb7c8b441dab25cb4b3c99fa08072c9cc9a9907","tarball":"https://registry.npmjs.org/filepath/-/filepath-0.1.0.tgz","integrity":"sha512-JUBDRdrlLKz9lI+r0VyfDhxLh38peyYnbTsP76PWPJPoYV38X10AyxjTgWGIbBQ83llw9YSrYFBo+KnDnZHiMQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDeqpQ2PeXxsl17R/2LAU4qoY6L/V5NHmHxtuAljwHQUwIhAOrnwbmXIFOSLId7fKc9bPq7Qr43G8e0fQ9EZvC2hqG/"}]},"_from":".","_npmVersion":"1.2.11","_npmUser":{"name":"kixxauth","email":"kris@kixx.name"},"maintainers":[{"name":"kixxauth","email":"kris@kixx.name"}],"directories":{}},"0.2.0":{"name":"filepath","version":"0.2.0","description":"A nice little interface for working with the filesystem in Node.js.","author":{"name":"Kris Walker","email":"kris@kixx.name","url":"http://www.kixx.name/"},"keywords":["filepath","files","directories","file","system","filesystem","path"],"repository":{"type":"git","url":"https://github.com/kixxauth/filepath.git"},"bugs":"https://github.com/kixxauth/filepath/issues","dependencies":{"iou":"0.1.0","ini":"1.1.0"},"_id":"filepath@0.2.0","dist":{"shasum":"152cb57b23c3107177f2335e880c2ace30f9822a","tarball":"https://registry.npmjs.org/filepath/-/filepath-0.2.0.tgz","integrity":"sha512-4KqbR4vbwBm9SgyHChcwRZXSJ2w+3Yhz/PvW8vnVtod65LT2hY3wgiROcwYGrqjNeWRA3qZUB3NO7NCY8hhJng==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIASLtQKnL1/X+I3+MOWaLD35sGfJJLIAiaEObdx70bIAAiBVcnXRFPmLwu0BV9Es0T63lSLtIdItm25mG09KMuwl1A=="}]},"_from":".","_npmVersion":"1.2.11","_npmUser":{"name":"kixxauth","email":"kris@kixx.name"},"maintainers":[{"name":"kixxauth","email":"kris@kixx.name"}],"directories":{}},"0.2.1":{"name":"filepath","version":"0.2.1","description":"A nice little interface for working with the filesystem in Node.js.","author":{"name":"Kris Walker","email":"kris@kixx.name","url":"http://www.kixx.name/"},"keywords":["filepath","files","directories","file","system","filesystem","path"],"repository":{"type":"git","url":"https://github.com/kixxauth/filepath.git"},"bugs":{"url":"https://github.com/kixxauth/filepath/issues"},"dependencies":{"iou":"0.1.0","ini":"1.1.0"},"_id":"filepath@0.2.1","dist":{"shasum":"d12caa17cd5a94ffdbf703034cdbb5c565682043","tarball":"https://registry.npmjs.org/filepath/-/filepath-0.2.1.tgz","integrity":"sha512-s5G3YdB0FUEKeraEstzleK7Tv9jL23x2mngsc9+6FFKmzXIENCngYpoy4IJn7a/n/eNMIv1qRQMDjU2QUbO3wA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAOLHAtE2f4yiAFwq8JbwpL+hf5elvSyWOXN2+rXV9L4AiEAqv7vcaRLjXS90eJWxx3ttJxoCbAAjwd2JSpEaiRN7PI="}]},"_from":".","_npmVersion":"1.2.23","_npmUser":{"name":"kixxauth","email":"kris@kixx.name"},"maintainers":[{"name":"kixxauth","email":"kris@kixx.name"}],"directories":{}},"0.3.0":{"name":"filepath","version":"0.3.0","description":"A little utility interface for working with the filesystem in Node.js.","author":{"name":"Kris Walker","email":"kris@kixx.name","url":"http://www.kixx.name/"},"keywords":["filepath","files","directories","file","system","filesystem","path"],"repository":{"type":"git","url":"https://github.com/kixxauth/filepath.git"},"bugs":{"url":"https://github.com/kixxauth/filepath/issues"},"dependencies":{"iou":"0.3.0"},"devDependencies":{"nodeunit":"0.8.1"},"_id":"filepath@0.3.0","dist":{"shasum":"18de7a1c3071e92c272a3659aa213fca7176e361","tarball":"https://registry.npmjs.org/filepath/-/filepath-0.3.0.tgz","integrity":"sha512-w4vefrMFkpGZqsLJCvkQpevGVG8NpkAM0okbZGejGf6WOIsdw/8vL9J2AQn9DsLtfSkgMxbbcXmYs+REND+VZQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDC6G1l0zg1pWknj2CPF1lDXA9B7SF9tlq5M1+rDUopZAiEAsOqlD48t5q4DKRyurwtaSG5AUCJDyssUcsBlEVUTyuI="}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"kixxauth","email":"kris@kixx.name"},"maintainers":[{"name":"kixxauth","email":"kris@kixx.name"}],"directories":{}},"0.4.0":{"name":"filepath","version":"0.4.0","description":"A little utility interface for working with the filesystem in Node.js.","author":{"name":"Kris Walker","email":"kris@kixx.name","url":"http://www.kixx.name/"},"keywords":["filepath","files","directories","file","system","filesystem","path"],"repository":{"type":"git","url":"https://github.com/kixxauth/filepath.git"},"bugs":{"url":"https://github.com/kixxauth/filepath/issues"},"dependencies":{"iou":"1.0.0"},"devDependencies":{"nodeunit":"0.8.1"},"_id":"filepath@0.4.0","dist":{"shasum":"9d9a3d67391919c63141738fb0fe348758f89724","tarball":"https://registry.npmjs.org/filepath/-/filepath-0.4.0.tgz","integrity":"sha512-xv15Mp4k2KGhAcb3OlYPPdIfcjKoR/9sM17bm0EiNgmsg1BZpK/4O+mDghvbAioEKhjnMkeIjdKhiBchAnBVLw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDVHGBnTm45zZJCzU6PSdQ10r/UWCx40eHXHjZ7JdDN4gIhAPWS2Bayy2/0I4ZX+ZbhTKyzAEUZ0wRE4UnX38xpxO1P"}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"kixxauth","email":"kris@kixx.name"},"maintainers":[{"name":"kixxauth","email":"kris@kixx.name"}],"directories":{}},"0.5.0":{"name":"filepath","version":"0.5.0","description":"A little utility interface for working with the filesystem in Node.js.","author":{"name":"Kris Walker","email":"kris@kixx.name","url":"http://www.kixx.name/"},"keywords":["filepath","files","directories","file","system","filesystem","path"],"repository":{"type":"git","url":"https://github.com/kixxauth/filepath.git"},"bugs":{"url":"https://github.com/kixxauth/filepath/issues"},"dependencies":{"iou":"2.0.0"},"devDependencies":{"nodeunit":"0.8.1"},"_id":"filepath@0.5.0","dist":{"shasum":"675e04b06e70eb5f9d24b8e414634073b951e389","tarball":"https://registry.npmjs.org/filepath/-/filepath-0.5.0.tgz","integrity":"sha512-WNn/CAFZaR4CejHAGq7c0aeA5ScSV/L9wUhpGn5fdfacNVkt4bG1RyHpSeayBU6sV61X2kywSPR2WSeRlQVqjQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA4InnHGimGwIhV0rGApYjhYLOTXAgeyq2iTiyUy31VQAiEAkPj/0FrS4jLnSnBnMrBSxsTQvlzAWzJspSMshyDw3cc="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"kixxauth","email":"kris@kixx.name"},"maintainers":[{"name":"kixxauth","email":"kris@kixx.name"}],"directories":{}},"0.7.0":{"name":"filepath","version":"0.7.0","description":"A little utility interface for working with the filesystem in Node.js.","author":{"name":"Kris Walker","email":"kris@kixx.name","url":"http://www.kixx.name/"},"keywords":["filepath","files","directories","file","system","filesystem","path"],"repository":{"type":"git","url":"https://github.com/kixxauth/filepath.git"},"bugs":{"url":"https://github.com/kixxauth/filepath/issues"},"dependencies":{"iou":"2.0.0"},"devDependencies":{"nodeunit":"0.8.1"},"_id":"filepath@0.7.0","dist":{"shasum":"3659623d1a10c70f029229a33bd65f88fb43fb7c","tarball":"https://registry.npmjs.org/filepath/-/filepath-0.7.0.tgz","integrity":"sha512-LSOqI+TX1YfFxIz4eE/t9N9GbheZmlchXiPuQGYj8rydhbA+CizHuiszGCLbwNSTrPsq0/QZZG6tCLU4fKEANg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD9it9OrSSl5HH2TA07yplyeQlK7/iaBzXPW1YzJ3KvOQIgPc94SQCJIp8sc4nPeU3qFHBHUhbXFEl7OEjwAqXpXHw="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"kixxauth","email":"kris@kixx.name"},"maintainers":[{"name":"kixxauth","email":"kris@kixx.name"}],"directories":{}},"0.8.1":{"name":"filepath","version":"0.8.1","description":"A little utility interface for working with the filesystem in Node.js.","author":{"name":"Kris Walker","email":"kris@kixx.name","url":"http://www.kixx.name/"},"keywords":["filepath","files","directories","file","system","filesystem","path"],"repository":{"type":"git","url":"https://github.com/kixxauth/filepath.git"},"bugs":{"url":"https://github.com/kixxauth/filepath/issues"},"dependencies":{"iou":"2.0.0"},"devDependencies":{"nodeunit":"0.8.1"},"homepage":"https://github.com/kixxauth/filepath","_id":"filepath@0.8.1","dist":{"shasum":"ba9a9cc1851954ee2b594123d0cefd0959989dc1","tarball":"https://registry.npmjs.org/filepath/-/filepath-0.8.1.tgz","integrity":"sha512-bQhLwITpmNq6o3wQHGIUxd2Ue0/B1QJkSjVIo3Vwf6LeU6hqyISc3LUHJt/pNtGbQ1rOVIN9UCezLISTBvUv9g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCYbmGHPcOWDcLd4qpkxruzzHtfzw/cGIo5nM3/d3r9UAIgGTCVjw3ZZVHVd0Vt8Maat/wuSShrL+DIkduVokolFmI="}]},"_from":".","_npmVersion":"1.3.21","_npmUser":{"name":"kixxauth","email":"kris@kixx.name"},"maintainers":[{"name":"kixxauth","email":"kris@kixx.name"}],"directories":{}},"1.0.0":{"name":"filepath","version":"1.0.0","description":"A cross platform utility interface for working with filesystems in Node.js.","author":{"name":"Kris Walker","email":"kris@kixx.name","url":"http://www.kixx.name/"},"repository":{"type":"git","url":"https://github.com/kixxauth/filepath.git"},"bugs":{"url":"https://github.com/kixxauth/filepath/issues"},"dependencies":{"iou":"~2.1.0"},"devDependencies":{"nodeunit":"~0.9.1"},"scripts":{"test":"node bin/run_tests.js test/"},"keywords":["filepath","files","directories","file","system","filesystem","path"],"gitHead":"ad7539b335ab93ce0be935c563a1d5c3f3a4d324","homepage":"https://github.com/kixxauth/filepath","_id":"filepath@1.0.0","_shasum":"e830844987f0584e1386a4e85fb32d2730bcbd06","_from":".","_npmVersion":"2.7.4","_nodeVersion":"0.12.2","_npmUser":{"name":"kixxauth","email":"kris@kixx.name"},"maintainers":[{"name":"kixxauth","email":"kris@kixx.name"}],"dist":{"shasum":"e830844987f0584e1386a4e85fb32d2730bcbd06","tarball":"https://registry.npmjs.org/filepath/-/filepath-1.0.0.tgz","integrity":"sha512-cJAiptZoMZt+nyJwmMQuh3oQxgZvytvsZ50gvxRiIv4t1HeEhXSJ3wkarAR/rOZS1FnNzVFKzhbSzbH1BW+uRA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDGP+OmFTq7MHX0I4IwnmAqngd+h/Kf2FlAgP2SO+OmlgIgSD6eoJDfO+AsKR+TNRj36EB3G1Yuxq+M3GuNMyfz0l4="}]},"directories":{}},"1.1.0":{"name":"filepath","version":"1.1.0","description":"A cross platform utility interface for working with filesystems in Node.js.","author":{"name":"Kris Walker","email":"kris@kixx.name","url":"http://www.kixx.name/"},"scripts":{"lint":"xo","test":"xo && bin/run_tests.js test/"},"repository":{"type":"git","url":"https://github.com/kixxauth/filepath.git"},"bugs":{"url":"https://github.com/kixxauth/filepath/issues"},"dependencies":{"bluebird":"3.0.5"},"devDependencies":{"nodeunit":"0.9.1","xo":"0.10.1"},"keywords":["filepath","files","directories","file","system","filesystem","path"],"gitHead":"ad3eeb733da3c6e27230f8743c7fd397a6a8ef3d","homepage":"https://github.com/kixxauth/filepath","_id":"filepath@1.1.0","_shasum":"d7bdc94896d9752fa8fa237e275e9e98e63098ed","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"kixxauth","email":"kris@kixx.name"},"maintainers":[{"name":"kixxauth","email":"kris@kixx.name"}],"dist":{"shasum":"d7bdc94896d9752fa8fa237e275e9e98e63098ed","tarball":"https://registry.npmjs.org/filepath/-/filepath-1.1.0.tgz","integrity":"sha512-9y3ID8Day2xS9USTmHuhbzv3+gifRw6ZMN1ameBfZNpelw9Kr4e1jze2CV5sLQrAMnILAtWUZwM6iLAHW4YzfA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCVWbUMvZxWSb92IMeJkb8LqNSsq/3UGddnzPhGPzhjQwIgMfkXgPfZjaYLGRvZafYgM/3EDrdDjKAwt9eL/ovgE70="}]},"directories":{}}},"readme":"Filepath\n========\n\nA cross platform interface for working with the file system in Node.js programs. Yes, it works with both posix and win32. So there.\n\n[![NPM](https://nodei.co/npm/filepath.png?downloads=true)](https://nodei.co/npm/filepath/)\n\n[![npm version](https://badge.fury.io/js/filepath.svg)](https://badge.fury.io/js/filepath)\n\n__Built by [@kixxauth](https://twitter.com/kixxauth)__\n\nInstallation\n------------\nThe most common use of Filepath is to use it as a library. In that case, just include it in your Node.js project by adding a line for \"filepath\" in your `pacakge.json` dependencies. For more information about your `package.json` file, you should check out the npm documentation by running `npm help json`.\n\nAlternatively, you can quickly install Filepath for use in a project by running\n\n\tnpm install filepath\n\nwhich will install filepath in your `node_modules/` folder.\n\nQuick Start\n-----------\n### Load the module\n```JS\nvar filepath = require('filepath');\n```\n\n### Create a new FilePath instance\nFilePath.create just takes a string to create a new path object:\n```JS\nvar path = filepath.create(__filname);\n```\n\nIt's important to remember that a FilePath instance is *not* a String. The 'path' property of a FilePath instance is the string representation of the FilePath instance, which is the same thing as calling .toString().\n```JS\nconsole.log(path);\n// \"{ [String: '/Users/kris/filepath/README.md'] path: '/Users/kris/filepath/README.md' }\"\n\npath.path; // \"/Users/kris/filepath/README.md\"\npath.valueOf(); // \"/Users/kris/filepath/README.md\"\npath.toString(); // \"/Users/kris/filepath/README.md\"\npath + ''; // \"/Users/kris/filepath/README.md\"\n\nassert(path.path === path.toString())\n```\n\nAPI Reference\n-------------\n\n#### Class Methods\n* [.create()](#create)\n* [.root()](#root)\n* [.home()](#home)\n\n#### Instance Methods\n\n##### Manipulation\n* [#append](#append)\n* [#resolve](#resolve)\n* [#dir](#dir)\n* [#copy](#copy)\n* [#remove](#remove)\n* [#relative](#relative) (returns a String)\n\n##### To String\n* [#toString](#tostring)\n* [#valueOf](#valueof)\n* [#basename](#basename)\n* [#extname](#extname)\n* [#split](#split)\n* [#relative](#relative)\n\n##### Tests\n* [#exists](#exists)\n* [#isFile](#isfile)\n* [#isDirectory](#isdirectory)\n\n##### Reading and Writing\n* [#read](#read)\n* [#write](#write)\n* [#require](#require)\n* [#copy](#copy)\n\n##### Streams\n* [#newReadStream](#newreadstream)\n* [#newWriteStream](#newwritestream)\n\n##### Directories\n* [#mkdir](#mkdir)\n* [#list](#list)\n* [#recurse](#recurse)\n\n#### [About Promises](#promises)\n#### [About Error Handling](#error-handling)\n\n### Class Methods\n\n#### .create()\nReturns a new FilePath instance. Defaults to the current working directory if you don't pass any arguments.\n```JS\nvar path = filepath.create();\nassert(path.toString() === process.cwd());\npath.toString();\n// \"/Users/kris/projects/filepath\"\n```\nJoins multiple arguments into a single path object.\n```JS\nvar path = filepath.create(__dirname, 'foo', 'bar');\nassert(path.toString() === __dirname + '/foo/bar');\npath.path; // \"/Users/kris/projects/filepath/foo/bar\"\n```\n\n#### .root()\nReturns a FilePath instance representing the root system path.\n```JS\n// On a posix system:\nassert(filepath.root().toString() === '/');\n```\n\n#### .home()\nReturns a FilePath instance representing the users's home directory. This is achieved using environment variables `process.env.HOME` on posix and `process.env.USERPROFILE` on win32.\n```JS\nassert(filepath.home().toString() === '/home/kris');\n```\n\n### Instance Methods\n\n#### #append()\nJoins an arbitrary number of arguments and appends them onto the path. Returns a new FilePath instance, leaving the original intact.\n```JS\nvar path1 = filepath.create(__dirname);\nvar path2 = path1.append('foo', 'bar');\nvar path3 = path1.append('baz');\n\nassert(path1.toString() === __dirname);\nassert(path2.toString() === __dirname + '/foo/bar');\nassert(path3.toString() === __dirname + '/baz');\n```\n\n#### #resolve()\nResolves a relative path with this one. Returns a new FilePath instance, leaving the original intact.\n```JS\nvar path = filepath\n  .create('/home/kris/filepath/lib')\n  .resolve('../README.md');\n\nassert(path.toString() === '/home/kris/filepath/README.md');\n```\n\n#### #dir()\nPops off the file or directory basename. The same as doing `../` on a posix system. Returns a new FilePath instance.\n```JS\nvar path = filepath.create('/home/kris/filepath').dir();\n\nassert(path.toString() === '/home/kris');\n```\n\n#### #copy()\nCopies the current path to the given path. Resolves with a new FilePath instance representing the new location. Also can be invoked synchronously.\n\nSee also: [Promises](#promises) and [Error Handling](#error-handling)\n```JS\nfilepath\n  .create(__filename)\n  .copy('/tmp/README.md')\n  .then(function (target) {\n    // The callback value `target` is a new FilePath instance.\n    assert(target.toString() === '/tmp/README.md');\n  })\n  .catch(console.error);\n```\n\nPass in mixed parts as the target.\n```JS\nvar targetDir = filepath.root().append('tmp');\nfilepath\n  .create(__filename)\n  .copy(targetDir, 'README.md');\n```\n\nOr you can copy a file *synchronously*:\n```JS\nvar target = filepath\n  .create(__filename)\n  .copy('/tmp/README.md', {sync: true});\nassert(target.toString() === '/tmp/README.md');\n```\n\n#### #remove()\nRemoves a FilePath. This is done by calling native Node.js `fs.unlinkSync`. There is no asynchronous pattern for #remove(). Returns the FilePath instance.\n```JS\nvar path = filepath.create(__filename);\nassert(path.exists());\npath.remove();\nassert(!path.exists());\n```\n\n#### #toString()\nReturns the stringified version of a FilePath. This is the same thing as the `.path` attribute, and doing `path + ''`.\n```JS\npath.toString(); // \"/Users/kris/filepath/README.md\"\npath.path; // \"/Users/kris/filepath/README.md\"\npath.valueOf(); // \"/Users/kris/filepath/README.md\"\npath + ''; // \"/Users/kris/filepath/README.md\"\n```\n\n#### #valueOf()\nSame as #toString().\n\n#### #basename()\nReturns the last part of the path only. If you pass in the extension string, it will not be included in the returned part. Note that #basename() returns a *String* and *not* a FilePath instance.\n```JS\nvar path = filepath.create('/home/kris/projects/filepath/README.md');\nassert(path.basename() === 'README.md');\nassert(path.basename('.md') === 'README');\n```\n\n#### #extname()\nReturns the extension of the last part of the path. Note that #extname() returns a *String* and *not* a FilePath instance.\n```JS\nvar ext = filepath.create('/home/kris/projects/filepath/README.md').extname();\nassert(ext === '.md');\n```\n\n#### #split()\nSplits a FilePath into an Array of parts. Each element in the Array is a String.\n```JS\nvar parts = filepath.create('/home/kris/projects/filepath/README.md').split();\nassert(Array.isArray(parts));\nassert(parts[0] === 'home');\nassert(parts.pop() === 'README.md');\n```\n\n#### #relative()\nReturns the relative String required to reach the passed in path. Note that #relative() returns a *String* and *not* a FilePath instance.\n```JS\nvar rel = filepath\n  .create('/home/kris/projects/filepath/lib')\n  .relative('/home/kris/projects/filepath/test');\n\nassert(rel === '../test');\n```\n\n#### #exists()\nCheck to see if a FilePath is present on the filesystem. Returns a Boolean.\n```JS\nvar path = filepath.create(__dirname);\nassert(path.exists());\nassert(!path.append('foo').exists());\n```\n\n#### #isFile()\nCheck to see if a FilePath is a file type on the filesystem. This is accomplished using `stats.isFile()`. If the FilePath does not exist, #isFile() will return false rather than throwing an Error. Returns a Boolean.\n```JS\nvar path = filepath.create(__filename);\nassert(path.isFile());\n```\n\n#### #isDirectory()\nCheck to see if a FilePath is a directory type on the filesystem. This is accomplished using `stats.isDirectory()`. If the FilePath does not exist, #isFile() will return false rather than throwing an Error. Returns a Boolean.\n```JS\nvar path = filepath.create(__dirname)\nassert(path.isDirectory())\n```\n\n#### #read()\nReads the contents of a file. This can be called asynchronously (by default) or synchronously. If the path is not a file type, it will throw an `ExpectFileError`. The default encoding is 'utf8', which means you will get a String back. Set the encoding to `null` to get a Buffer instead. Any options passed in (including 'encoding') will be passed to Node.js native `fs.readFile()`.\n\nread() returns a Promise for the file contents unless you run it synchronously. If the file does not exist, it will return null. See also: [Promises](#promises) and [Error Handling](#error-handling)\n```JS\nvar path = filepath.create(__filename);\n\n// #read() returns a promise object with #then() and #catch() methods.\npath.read()\n  .then(function assertResult(contents) {\n    assert(typeof contents === 'string');\n  }).catch(console.error);\n\n// Or you can read a file *synchronously*:\nvar readmeContents = path.read({sync: true, encoding: null});\nassert(readmeContents instanceof Buffer);\n```\n\n#### #write()\nWrites a file with the given content. This can be called asynchronously (by default) or synchronously. If the path is not a file type, it will throw an `ExpectFileError`. If the file does not exist, it will be created. The default encoding is 'utf8' which means you are passing #write() a String. Set the encoding to `null` to pass a Buffer instead. Any options passed in (including 'encoding') will be passed to Node.js native `fs.writeFile()`.\n\nwrite() returns a Promise for the FilePath instance unless you run it synchronously. See also: [Promises](#promises) and [Error Handling](#error-handling)\n```JS\nvar path = filepath.create('/tmp/new_file.txt')\n\npath.write('Hello world!\\n')\n  .then(function assertResult(returnedPath) {\n    assert(returnedPath === path);\n    assert(path.read({sync: true}) === 'Hello world!\\n');\n  })\n  .catch(console.error);\n\n// Or you can write a file *synchronously*:\nvar syncPath = filepath.create('/tmp/new_file_sync.txt');\nsyncPath.write('Overwrite with this text', {sync: true});\nassert(syncPath.read({sync: true}) === 'Hello world!\\n');\n```\n\n#### #require()\nRequire a module using Node.js native `require()`. You'll need to pass in the current `require` function to have the correct context for requiring a module.\n```JS\nvar path = filepath.create(__dirname, 'index.js');\nvar filepath = path.require(require);\nassert(filepath === filepath);\n```\n\n#### #newReadStream()\nCreates a new Read Stream from the FilePath. This can be used in streaming APIs.\n```JS\nvar FS = require('fs');\nvar stream = filepath.create(__filename).newReadStream();\nassert(stream instanceof FS.ReadStream);\n```\n\n#### #newWriteStream()\nCreates a new Write Stream from the FilePath. This can be used in streaming APIs.\n```JS\nvar FS = require('fs');\nvar stream = filepath.create('/tmp/new_file.txt').newWriteStream();\nassert(stream instanceof FS.WriteStream);\n```\n\n#### #mkdir()\nCreate a directory, unless it already exists. Will create any parent directories which do not already exist. Works kinda like 'mkdir -P'. Returns the FilePath instance.\n```JS\nvar path = filepath.create('/tmp/some/new/deep/dir').mkdir();\nassert(path instanceof filepath.FilePath);\nassert(path.isDirectory());\n```\n\n#### #list()\nList paths in a directory. Listing a directory returns an Array of fully resolved FilePath instances.\n```JS\nvar li = filepath.create(__dirname).list();\nassert(li[4] instanceof filepath.FilePath);\nassert(li[4].toString() === '/home/kris/projects/filepath/README.md');\n```\n\n#### #recurse()\nRecursively walk a directory tree. The given callbak with be called with fully resolved FilePath instances. Returns the FilePath instance.\n```JS\nfilepath.create(__dirname).recurse(function (path) {\n  assert(path instanceof filepath.FilePath);\n  assert(path.toString().indexOf(__dirname) === 0);\n});\n```\n\n### Promises\nFilePath uses [Bluebird](https://github.com/petkaantonov/bluebird/) promises from end to end. This provides a full featured and consistent API for some of the most common asynchronous flows in your program.\n\nBluebird also has a unique and very useful error handling mechanism (see below).\n\n### Error Handling\nFilePath defines 4 Error types:\n* FilePathError\n* NotFoundError\n* ExpectDirectoryError\n* ExpectFileError\n\n`NotFoundError`, `ExpectDirectoryError`, and `ExpectFileError` are subtypes of `FilePathError`. This allows you to use [Bluebirds error handling](http://bluebirdjs.com/docs/api/catch.html) in .catch() handlers:\n\n```JS\n// Catch only an ExpectFileError\nfilepath.create(__dirname)\n  .read()\n  .then(function () { /* This will not be called */ })\n  .catch(filepath.ExpectFileError, function (err) {\n    // handle the ExpectFileError\n  })\n  .catch(function (err) {\n    // handle the unexpected Error\n  });\n```\n\n## Testing\nTo run the tests, just do\n\n  npm test\n\nYou should see the test results output.\n\n\nCopyright and License\n---------------------\nCopyright (c) 2013-2015 by Kris Walker <kris@kixx.name> (http://www.kixx.name).\n\nUnless otherwise indicated, all source code is licensed under the MIT license.\nSee LICENSE for details.\n","maintainers":[{"name":"kixxauth","email":"kris@kixx.name"}],"time":{"modified":"2022-06-18T00:43:36.124Z","created":"2013-03-01T10:25:12.395Z","0.1.0":"2013-03-01T10:25:13.262Z","0.2.0":"2013-03-30T20:03:10.893Z","0.2.1":"2013-05-30T01:49:25.648Z","0.3.0":"2013-09-30T00:31:56.599Z","0.4.0":"2014-01-08T11:11:04.485Z","0.5.0":"2014-01-08T11:36:48.210Z","0.7.0":"2014-01-08T11:49:24.117Z","0.8.1":"2014-01-11T10:07:25.776Z","1.0.0":"2015-05-19T22:34:56.745Z","1.1.0":"2015-11-07T03:48:32.715Z"},"author":{"name":"Kris Walker","email":"kris@kixx.name","url":"http://www.kixx.name/"},"repository":{"type":"git","url":"https://github.com/kixxauth/filepath.git"},"users":{"yabasha":true},"homepage":"https://github.com/kixxauth/filepath","keywords":["filepath","files","directories","file","system","filesystem","path"],"bugs":{"url":"https://github.com/kixxauth/filepath/issues"},"readmeFilename":"README.md"}