Skip to content

Commit 88524cd

Browse files
committed
Merge pull request phaserjs#1851 from rblopes/detect-nwjs-electro
Changes for nw.js-like environment detection code
2 parents 4080231 + b64d817 commit 88524cd

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/system/Device.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ Phaser.Device = function () {
8787
*/
8888
this.nodeWebkit = false;
8989

90+
/**
91+
* @property {boolean} electron - Is the game running under GitHub Electron?
92+
* @default
93+
*/
94+
this.electron = false;
95+
9096
/**
9197
* @property {boolean} ejecta - Is the game running under Ejecta?
9298
* @default
@@ -913,15 +919,11 @@ Phaser.Device._initialize = function () {
913919
device.node = true;
914920
}
915921

916-
if (device.node)
922+
if (device.node && typeof window.process.versions === 'object')
917923
{
918-
try {
919-
device.nodeWebkit = (typeof require('nw.gui') !== "undefined");
920-
}
921-
catch(error)
922-
{
923-
device.nodeWebkit = false;
924-
}
924+
device.nodeWebkit = !!window.process.versions['node-webkit'];
925+
926+
device.electron = !!window.process.versions.electron;
925927
}
926928

927929
if (navigator['isCocoonJS'])

0 commit comments

Comments
 (0)