diff --git a/src/js/utils/Environment.js b/src/js/utils/Environment.js index 58b973a2..a6b6cfb0 100644 --- a/src/js/utils/Environment.js +++ b/src/js/utils/Environment.js @@ -9,11 +9,11 @@ ns.Environment = { detectNodeWebkit : function () { - var isNode = (typeof process !== "undefined" && typeof require !== "undefined"); + var isNode = (typeof window.process !== "undefined" && typeof window.require !== "undefined"); var isNodeWebkit = false; if (isNode) { try { - isNodeWebkit = (typeof require('nw.gui') !== "undefined"); + isNodeWebkit = (typeof window.require('nw.gui') !== "undefined"); } catch (e) { isNodeWebkit = false; } diff --git a/src/js/utils/FileUtilsDesktop.js b/src/js/utils/FileUtilsDesktop.js index 2f596e74..6a724e1e 100644 --- a/src/js/utils/FileUtilsDesktop.js +++ b/src/js/utils/FileUtilsDesktop.js @@ -59,7 +59,7 @@ * @callback callback */ saveToFile : function(content, filename, callback) { - var fs = require('fs'); + var fs = window.require('fs'); fs.writeFile(filename, content, function(err){ if (err) { //throw err; @@ -70,7 +70,7 @@ }, readFile : function(filename, callback) { - var fs = require('fs'); + var fs = window.require('fs'); // NOTE: currently loading everything as utf8, which may not be desirable in future fs.readFile(filename, 'utf8', function(err, data){ if (err) {