qrohlf / trianglify

Algorithmically generated triangle art
http://qrohlf.com/trianglify/
GNU General Public License v3.0
10.08k stars 669 forks source link

Avoid false positives in Node environment check #75

Closed AlexNisnevich closed 7 years ago

AlexNisnevich commented 7 years ago

I'm working with a browser environment where the process global variable is defined. The Node check should be a little more specific to avoid false positives.

qrohlf commented 7 years ago

Sorry for the slow review on this. I believe this will TypeError in browser environments where the process global variable is defined but does not have a title attribute.

Maybe something along the lines of

(typeof process === 'object') &&
(typeof process.versions === 'object') &&
(typeof process.versions.node !== 'undefined')

will meet your needs?

AlexNisnevich commented 7 years ago

Ah yeah, that works!

AlexNisnevich commented 7 years ago

Ok @qrohlf, the PR is ready for review again.

qrohlf commented 7 years ago

looks good, thanks for this

qrohlf commented 7 years ago

@AlexNisnevich these changes are now published on npm as v1.1.0