agea/CmisJS

Detect nodeJS environment

Closed this issue · 1 comments

wiser commented

Hi,

Since eff9c27 commit our node environment is not correctly detected anymore.
We use the Adobe CEP plateform (https://github.com/Adobe-CEP/) and this environment also use Node and a navigator instance (nw.js).
So the test :
var isNode = isCommonJSModules && typeof window === 'undefined';
is not compliant with these environments because they have a window object...

Can I supply to you a PR with a more accurate test using the process && process.title == 'node' variables ?

BR.
Wiser

agea commented

Hello, I also found that someone uses something like this to check for Node,

var isNode = false;
try {
 isNode = Object.prototype.toString.call(process) === '[object process]' 
} catch(e) {}

please just check which you think is the better way before sending a PR,

thank you