suppressing build errors when referring to "require" and "process"

This commit is contained in:
Lee Grey 2015-03-24 22:58:42 +13:00
parent 93deb1c2c5
commit eb4941417c
2 changed files with 4 additions and 1 deletions

View file

@ -9,9 +9,10 @@
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) {
var require = window["require"];
try {
isNodeWebkit = (typeof require('nw.gui') !== "undefined");
} catch (e) {

View file

@ -59,6 +59,7 @@
* @callback callback
*/
saveToFile : function(content, filename, callback) {
var require = window["require"]; // suppress build error
var fs = require('fs');
fs.writeFile(filename, content, function(err){
if (err) {
@ -70,6 +71,7 @@
},
readFile : function(filename, callback) {
var require = window["require"]; // suppress build error
var fs = require('fs');
// NOTE: currently loading everything as utf8, which may not be desirable in future
fs.readFile(filename, 'utf8', function(err, data){