{"dist":{"shasum":"7659a48f0b750dddaafb437f5a6171ce29bd13a3","tarball":"https://registry.npmjs.org/meta-path/-/meta-path-0.0.5.tgz","integrity":"sha512-1xEstxcgPALiEkMuG/EuYNPRkPzChBfPAlnsWk0FEHa6I4W37z5Zn+Mbp9I04ElJSY/77Nhw3Jz2DVU3NGHORg==","signatures":[{"sig":"MEUCIQD5ieMjQIoXv37E0vaiRWoCceXVmfKEQyGcp/1ArcSIKAIgOyyMbXnC3oMbgvb4DolIvfqKbRdL8UIXI1VqNqiEous=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"meta-path","name":"meta-path","author":{"name":"Gabriel Llamas","email":"gaglekas@gmail.com"},"readme":"meta-path\r\n=========\r\n\r\n_Node.js project_\r\n\r\n#### Provides metadata information about resource paths (file system and shared network) ####\r\n\r\nVersion: 0.0.5\r\n\r\nThe `path.normalize()` function has a lot of bugs when dealing with Windows UNC paths. Its result is not consistent between equivalent paths nor between Windows and Linux nor between Node.js versions themselves. What a mess!\r\n\r\nTry to execute this code in Node.js v0.6.x both on Windows and Linux, you'll be astonished with the different results when in fact, both paths should be normalized to `//a/b`.\r\n\r\n```javascript\r\nvar path = require (\"path\");\r\nconsole.log (path.normalize (\"//a/b\"));\r\nconsole.log (path.normalize (\"//a//b\"));\r\n```\r\n\r\nNode.js developpers are aware of these bugs (see [#3066](https://github.com/joyent/node/issues/3066) and [#3610](https://github.com/joyent/node/issues/3610)).\r\n\r\nFurthermore, did you know why you always see the concatenation of `__dirname` with a path? It's because the `process.cwd()` function returns the shell's current working directory instead of the home path of your application.\r\n\r\n```\r\n$ pwd\r\n/home/gll\r\n$ mkdir a\r\n$ cat > a/app.js\r\nconsole.log (process.cwd ())\r\n$ node a/app.js\r\n/home/gll\r\n```\r\n\r\nAs you see, the project base path \"should\" be `/home/gll/a`. If you don't understand this simple feature and use any built-in function found in the `fs` module you application will be broken. It's not the same `fs.existsSync(\"app.js\")` if you are in `/home/gll` or in `home/gll/a`. In the first case, the function will return false and in the second case it will return true. If you prefix the path with `__dirname` the function will work in both cases, `fs.existsSync(__dirname + \"/app.js\")`.\r\n\r\nThis solution is correct if you're not writing a third-party module, `__dirname` has a local significance, it contains the absolute path of the directory from where `__dirname` is executed, that is, if it's used in `/home/gll/a/app.js` it will contain `/home/gll/a` if we follow with the previous example.\r\n\r\nThis library aims to fix all the path bugs to provide a backward compatibility, be consistent between Windows and Linux and resolve the relative path issue for third-party modules.\r\n\r\n#### Installation ####\r\n\r\n```\r\nnpm install meta-path\r\n```\r\n\r\n#### Example ####\r\n\r\n```javascript\r\nvar meta = require (\"meta-path\");\r\n\r\nprocess.chdir (\"..\");\r\n\r\n//If you only want to get the current working directory fix (faster than calling meta()):\r\nconsole.log (meta.fix ());\r\n\r\n/*\r\nPrints: \"meta-path\"\r\n*/\r\n\r\n//Relative\r\nconsole.log (meta (\"D:a/b\"));\r\n\r\n/*\r\nPrints (Windows backslashes, Linux slashes):\r\n\r\n{\r\n\tisAbsolute: false,\r\n\tisNetwork: false,\r\n\tisRelative: true,\r\n\tnormalized: \"D:a\\\\b\",\r\n\tprefix: \"D:\",\r\n\tnormalizedWithoutPrefix: \"\\\\a\\\\b\",\r\n\trelativeFix: \"meta-path\",\r\n\tnormalizedFixed: \"D:meta-path\\\\a\\\\b\",\r\n\tnormalizedFixedWithoutPrefix: \"meta-path\\\\a\\\\b\"\r\n}\r\n*/\r\n\r\n//Absolute\r\nconsole.log (meta (\"D:/a/b\"));\r\n\r\n/*\r\nPrints (Windows backslashes, Linux slashes):\r\n\r\n{\r\n\tisAbsolute: true,\r\n\tisNetwork: false,\r\n\tisRelative: false,\r\n\tnormalized: \"D:\\\\a\\\\b\",\r\n\tprefix: \"D:\",\r\n\tnormalizedWithoutPrefix: \"\\\\\\\\a\\\\b\"\r\n}\r\n*/\r\n\r\n//Shared network\r\nconsole.log (meta (\"smb://a/b\"));\r\n\r\n/*\r\nPrints (Windows backslashes, Linux slashes):\r\n\r\n{\r\n\tisAbsolute: false,\r\n\tisNetwork: true,\r\n\tisRelative: false,\r\n\tnormalized: \"smb:\\\\\\\\a\\\\b\",\r\n\tprefix: \"smb:\",\r\n\tnormalizedWithoutPrefix: \"\\\\\\\\a\\\\b\"\r\n}\r\n*/\r\n```","engines":{"node":"*"},"_npmUser":{"name":"Gagle","email":"gaglekas@gmail.com"},"keywords":["meta","fs","path","relative","absolute","unc","network","resource","fix","__dirname","backward","compatibility"],"licenses":[{"url":"http://www.opensource.org/licenses/mit-license.html","type":"MIT"}],"deprecated":"use rwd","repository":{"url":"git://github.com/Gagle/Node-MetaPath.git","type":"git"},"_npmVersion":"1.1.66","description":"Provides metadata information about resource paths (file system and shared network)","directories":{},"maintainers":[{"name":"Gagle","email":"gaglekas@gmail.com"}],"dependencies":{"is-global":"*"},"readmeFilename":"README.md","_id":"meta-path@0.0.5","version":"0.0.5"}