Skip to content

Commit

Permalink
Add process.browser check for inNode
Browse files Browse the repository at this point in the history
  • Loading branch information
coverslide authored and Richard Hoffman committed Jan 29, 2015
1 parent de86100 commit f506d99
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions qr.js
Original file line number Diff line number Diff line change
Expand Up @@ -1188,17 +1188,20 @@

// Export `qr` for node.js and CommonJS.
if (typeof exports !== 'undefined') {
inNode = true;
// Detect if we are using CommonJS *without* Node i.e. browserify
inNode = !(typeof process !== 'undefined' && process.browser); // browserify-specific check

if (typeof module !== 'undefined' && module.exports) {
exports = module.exports = qr;
}
exports.qr = qr;

// Import required node.js modules.
Canvas = require('canvas');
Image = Canvas.Image;
fs = require('fs');

if (inNode) {
// Import required node.js modules.
Canvas = require('canvas');
Image = Canvas.Image;
fs = require('fs');
}
} else if (typeof define === 'function' && define.amd) {
define(function () {
return qr;
Expand Down

0 comments on commit f506d99

Please sign in to comment.