Skip to content

Commit 3a9f869

Browse files
committed
Merge pull request phaserjs#1129 from videlais/patch-2
Device detection of Node-Webkit
2 parents 2d4d1a0 + a084027 commit 3a9f869

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

src/system/Device.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,19 @@ Phaser.Device = function (game) {
4343
* @default
4444
*/
4545
this.cordova = false;
46-
46+
47+
/**
48+
* @property {boolean} node - Is the game running under Node.js?
49+
* @default
50+
*/
51+
this.node = false;
52+
53+
/**
54+
* @property {boolean} nodeWebkit - Is the game running under Node-Webkit?
55+
* @default
56+
*/
57+
this.nodeWebkit = false;
58+
4759
/**
4860
* @property {boolean} ejecta - Is the game running under Ejecta?
4961
* @default
@@ -631,7 +643,21 @@ Phaser.Device.prototype = {
631643
{
632644
this.cordova = true;
633645
}
634-
646+
647+
if(typeof process !== "undefined" && typeof require !== "undefined")
648+
{
649+
this.node = true;
650+
}
651+
652+
if(this.node)
653+
{
654+
try {
655+
this.nodeWebkit = (typeof require('nw.gui') !== "undefined");
656+
} catch(error) {
657+
this.nodeWebkit = false;
658+
}
659+
}
660+
635661
if (navigator['isCocoonJS'])
636662
{
637663
this.cocoonJS = true;

0 commit comments

Comments
 (0)