Added NODE_PATH support and tests.

---

[This is the 
code](https://github.com/nodejs/node/blob/master/lib/internal/modules/cjs/loader.js#L789)
 that generates those GLOBAL_FOLDERS. It's straightforward to replicate this 
functionality in cordova-fetch, but the way it finds the node_prefix [has 
changed because the node binary 
moved](https://github.com/nodejs/node-v0.x-archive/blob/061151c/lib/module.js#L511),
 and I don't know if it could in the future.

Unfortunately, `globalPaths` seems to be undocumented, though it can be 
accessed through `require('module').globalPaths` in all node versions thus far, 
as far as I can tell. It can also be accessed by looking at the last three 
items of `module.path`.

All of these options have drawbacks, and supporting GLOBAL_FOLDERS would be 
"mostly for historic reasons". @raphinesse, up to you whether to support them 
and which option has the best trade-offs for the cordova project.

---

As far as testing global modules, I only see two ways of testing it:

1. actually install a global module and uninstall it afterwards, which could be 
disruptive and require sudo on some systems
2. use NODE_PATH to simulate global modules, but this is indistinguishable from 
testing NODE_PATH support


[ Full content available at: https://github.com/apache/cordova-fetch/pull/44 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to