Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ Api.prototype.loadApi = function () {

function addMainProcessModules() {
api.electron.remote = {};
if (typeof electron.remote !== 'object') return;
Object.getOwnPropertyNames(electron.remote).forEach(function (key) {
if (ignoreModule(key)) return;
if (isRemoteFunction(key)) {
Expand All @@ -161,6 +162,7 @@ Api.prototype.loadApi = function () {
}

function addBrowserWindow() {
if (typeof electron.remote !== 'object') return;
const currentWindow = electron.remote.getCurrentWindow();
for (const name in currentWindow) {
if (ignoreApi(name)) continue;
Expand All @@ -172,6 +174,7 @@ Api.prototype.loadApi = function () {
}

function addWebContents() {
if (typeof electron.remote !== 'object') return;
const webContents = electron.remote.getCurrentWebContents();
for (const name in webContents) {
if (ignoreApi(name)) continue;
Expand Down
21 changes: 20 additions & 1 deletion lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,26 @@ Application.prototype.stop = function () {
};

if (self.api.nodeIntegration) {
self.client.electron.remote.app.quit().then(endClient, reject);
// Check if electron remote app has really a quit() function
if (
Object.prototype.hasOwnProperty.call(self.client.electron, 'remote') &&
Object.prototype.hasOwnProperty.call(
self.client.electron.remote,
'app'
) &&
typeof self.client.electron.remote.app.quit === 'function'
) {
self.client.electron.remote.app.quit().then(endClient, reject);
} else {
const fakeAppQuit = new Promise(function (resolve, reject) {
try {
resolve();
} catch (error) {
reject(Error('fakeAppQuit Promise not valid'));
}
});
fakeAppQuit.then(endClient, reject);
}
} else {
self.client
.windowByIndex(0)
Expand Down