Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPII-4253: Added support for dynamic loading of OS-specific and 'no-os' modules #169

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
11 changes: 10 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ https://github.com/GPII/universal/blob/master/LICENSE.txt
"use strict";

var app = require("electron").app;
var os = require("os");

// Perform this check early, do avoid any delay.
var singleInstance = app.requestSingleInstanceLock();
Expand Down Expand Up @@ -61,7 +62,15 @@ app.on("second-instance", function (event, commandLine) {
// this module is loaded relatively slowly
// it also loads gpii-universal
// NOTE: if the OS-specific support package was not loaded successfully, the require(".../index.js") function will throw an exception
require("gpii-windows/index.js");
switch(os.platform()) {
case "win32":
require("gpii-windows/index.js");
break;
default:
// use the no-os stubs if the host is not running a supported OS
require("gpii-no-os/index.js");
break;
}

require("./index.js");

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"shelljs": "0.8.2"
},
"optionalDependencies": {
"gpii-no-os": "git+https://github.com/GPII/gpii-no-os.git",
"gpii-windows": "0.3.0-dev.20191204T181313Z.b920f98.GPII-4253"
},
"scripts": {
Expand Down