{"_id":"is-global","_rev":"70851","name":"is-global","description":"Checks whether Node.js is running a global module","dist-tags":{"latest":"0.1.0"},"maintainers":[{"name":"gagle","email":"gabriel_llamas_llopis@yahoo.es"}],"time":{"modified":"2021-06-03T10:23:23.000Z","created":"2012-12-04T17:59:10.641Z","0.1.0":"2014-01-01T09:50:44.492Z","0.0.2":"2013-01-25T09:11:56.341Z","0.0.1":"2012-12-04T17:59:10.641Z"},"users":{},"author":{"name":"Gabriel Llamas","email":"gagle@outlook.com"},"repository":{"type":"git","url":"git://github.com/gagle/node-is-global.git"},"versions":{"0.1.0":{"name":"is-global","version":"0.1.0","description":"Checks whether Node.js is running a global module","keywords":["global","module"],"author":{"name":"Gabriel Llamas","email":"gagle@outlook.com"},"repository":{"type":"git","url":"git://github.com/gagle/node-is-global.git"},"engines":{"node":">=0.10"},"license":"MIT","main":"lib","readmeFilename":"README.md","bugs":{"url":"https://github.com/gagle/node-is-global/issues"},"homepage":"https://github.com/gagle/node-is-global","_id":"is-global@0.1.0","dist":{"shasum":"74305fd0f8661b3fdfe802d11aa970668dcdcd33","size":1877,"noattachment":false,"key":"/is-global/-/is-global-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/is-global/download/is-global-0.1.0.tgz"},"_from":".","_npmVersion":"1.3.14","_npmUser":{"name":"gagle","email":"gabriel_llamas_llopis@yahoo.es"},"maintainers":[{"name":"gagle","email":"gabriel_llamas_llopis@yahoo.es"}],"directories":{},"publish_time":1388569844492,"_cnpm_publish_time":1388569844492,"_hasShrinkwrap":false},"0.0.2":{"name":"is-global","version":"0.0.2","description":"Checks whether Node.js is running a global module","keywords":["global","module"],"author":{"name":"Gabriel Llamas","email":"gaglekas@gmail.com"},"repository":{"type":"git","url":"git://github.com/Gagle/Node-IsGlobal.git"},"engines":{"node":"*"},"licenses":[{"type":"MIT","url":"http://www.opensource.org/licenses/mit-license.html"}],"main":"lib/is-global","readmeFilename":"README.md","_id":"is-global@0.0.2","dist":{"shasum":"ad99a5d26b4efeaa9e0447fabf7df1d8305d96c7","size":2161,"noattachment":false,"key":"/is-global/-/is-global-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/is-global/download/is-global-0.0.2.tgz"},"_from":".","_npmVersion":"1.2.2","_npmUser":{"name":"Gagle","email":"gaglekas@gmail.com"},"maintainers":[{"name":"gagle","email":"gabriel_llamas_llopis@yahoo.es"}],"directories":{},"publish_time":1359105116341,"_cnpm_publish_time":1359105116341,"_hasShrinkwrap":false},"0.0.1":{"name":"is-global","version":"0.0.1","description":"Checks whether Node.js is running a global module.","keywords":["global","module"],"author":{"name":"Gabriel Llamas","email":"gaglekas@gmail.com"},"repository":{"type":"git","url":"git://github.com/Gagle/Node-IsGlobal.git"},"engines":{"node":"*"},"licenses":[{"type":"MIT","url":"http://www.opensource.org/licenses/mit-license.html"}],"main":"is-global","readmeFilename":"README.md","_id":"is-global@0.0.1","dist":{"shasum":"6a32823886c774e730d34bf4c14f40f341d65435","size":2189,"noattachment":false,"key":"/is-global/-/is-global-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/is-global/download/is-global-0.0.1.tgz"},"_npmVersion":"1.1.66","_npmUser":{"name":"Gagle","email":"gaglekas@gmail.com"},"maintainers":[{"name":"gagle","email":"gabriel_llamas_llopis@yahoo.es"}],"directories":{},"publish_time":1354643950641,"_cnpm_publish_time":1354643950641,"_hasShrinkwrap":false}},"readme":"is-global\r\n=========\r\n\r\n_Node.js project_\r\n\r\n#### Checks whether Node.js is running a global module ####\r\n\r\nVersion: 0.0.1\r\n\r\nThere are times you need to know whether Node.js is executing a global module, typically when you're writing a third-party module. For these cases this little module can help you.\r\n\r\nOn Linux the `_` environment variable is compared with the `process.execPath`. Simple, quick and works in all situations because it doesn't depend on the current working directory.\r\n\r\nOn Windows there are two ways:\r\n\r\n* __Synchronous__\r\n\r\n\tThe `PATH` environment variable is used. Node.js scripts running inside `<npm_install_dir>/node_modules` will always return true, e.g.:\r\n\r\n\t```\r\n\tnpm_install_dir = C:\\Users\\<user>\\AppData\\Roaming\\npm\r\n\tnode <npm_install_dir>\\node_modules\\myscript.js\r\n\t```\r\n\r\n\tTherefore, don't run scripts inside the npm install directory or this module will always return true. No one does that so you can assume that on Windows platform it detects the global module execution correctly. To ensure that this module doesn't break your code you can put a big warning in your documentation.\r\n\r\n* __Asynchronous__\r\n\r\n\tThe approach consists on reading the `process.mainModule.paths[0]` variable and search for the first package.json file, starting in the current path and ending at the `/` root's path. If the first package.json file contains a `bin` property then Node.js is running a global module. Works in all situations. If an I/O error is produced while reading the package.json file the function will silently return false.\r\n\r\nThis library provides both versions. The first is typically used when you are in a synchronous context, for example inside a constructor function. On Linux both versions use the same described approach, that is, doesn't perform any I/O call.\r\n\r\n#### Installation ####\r\n\r\n```\r\nnpm install is-global\r\n```\r\n\r\n#### Example ####\r\n\r\n```javascript\r\nvar isGlobal = require (\"is-global\");\r\n//The result is cached, you don't need to save the result in your application\r\n\r\n//Synchronous version\r\nconsole.log (isGlobal ());\r\n\r\n//Asynchronous version\r\nisGlobal (console.log);\r\n```","_attachments":{},"readmeFilename":"README.md","homepage":"https://github.com/gagle/node-is-global","bugs":{"url":"https://github.com/gagle/node-is-global/issues"},"license":"MIT"}