Tests for both Node and Node-Webkit

This commit is contained in:
Dan Cox 2014-08-27 22:00:14 -04:00
parent 2065c3a77a
commit a0840274f7

View file

@ -44,6 +44,12 @@ Phaser.Device = function (game) {
*/
this.cordova = false;
/**
* @property {boolean} node - Is the game running under Node.js?
* @default
*/
this.node = false;
/**
* @property {boolean} nodeWebkit - Is the game running under Node-Webkit?
* @default
@ -640,7 +646,16 @@ Phaser.Device.prototype = {
if(typeof process !== "undefined" && typeof require !== "undefined")
{
this.nodeWebkit = true;
this.node = true;
}
if(this.node)
{
try {
this.nodeWebkit = (typeof require('nw.gui') !== "undefined");
} catch(error) {
this.nodeWebkit = false;
}
}
if (navigator['isCocoonJS'])