Skip to content

Commit

Permalink
Merge pull request #18 from glawson/adds-electron-path
Browse files Browse the repository at this point in the history
fix: adds electron path as config option
  • Loading branch information
glawson authored Oct 7, 2020
2 parents b0036ec + a96cdc5 commit 6fe6924
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ const deeplink = new Deeplink([config]);
// type: boolean
// If true, outputs logging. Uses electron-log, so files are appened/created for prod.
debugLogging: false|true
// optional, default: '/node_modules/electron/dist/Electron.app'
// type: string
// String representing the location of Electron relative to the app root.
electronPath: [string]
}
```

Expand Down
1 change: 1 addition & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ interface DeeplinkConfig {
isDev?: boolean;
isYarn?: boolean;
debugLogging?: boolean;
electronPath: string;
}
declare class Deeplink extends EventEmitter {
private appPath?;
Expand Down
6 changes: 3 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var Deeplink = /** @class */ (function (_super) {
var bundleURL = infoPlistTemplate.replace(/{PROTOCOL}/g, protocol);
var infoPlist;
_this.appPath = _this.app.getAppPath();
_this.electronPath = path.join(_this.appPath, '/node_modules/electron/dist/Electron.app');
_this.electronPath = path.join(_this.appPath, _this.config.electronPath);
_this.infoPlistFile = path.join(_this.electronPath, '/Contents/Info.plist');
_this.infoPlistFileBak = path.join(_this.electronPath, '/Contents/Info.deeplink');
if (fs.existsSync(_this.infoPlistFileBak)) {
Expand Down Expand Up @@ -94,9 +94,9 @@ var Deeplink = /** @class */ (function (_super) {
_this.getLogfile = function () {
return _this.logger ? _this.logger.transports.file.getFile().path : 'debugLogging is disabled';
};
var app = config.app, mainWindow = config.mainWindow, protocol = config.protocol, _a = config.isDev, isDev = _a === void 0 ? false : _a, _b = config.debugLogging, debugLogging = _b === void 0 ? false : _b;
var app = config.app, mainWindow = config.mainWindow, protocol = config.protocol, _a = config.isDev, isDev = _a === void 0 ? false : _a, _b = config.debugLogging, debugLogging = _b === void 0 ? false : _b, _c = config.electronPath, electronPath = _c === void 0 ? '/node_modules/electron/dist/Electron.app' : _c;
_this.checkConfig(config);
_this.config = { protocol: protocol, debugLogging: debugLogging, isDev: isDev };
_this.config = { protocol: protocol, debugLogging: debugLogging, isDev: isDev, electronPath: electronPath };
_this.app = app;
_this.mainWindow = mainWindow;
if (debugLogging) {
Expand Down
8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ interface DeeplinkConfig {
isDev?: boolean;
isYarn?: boolean;
debugLogging?: boolean;
electronPath: string;
}

interface InstanceConfig {
protocol: string | null;
debugLogging: boolean;
isDev: boolean;
electronPath: string;
}

class Deeplink extends EventEmitter {
Expand All @@ -73,11 +75,11 @@ class Deeplink extends EventEmitter {

constructor(config: DeeplinkConfig) {
super();
const { app, mainWindow, protocol, isDev = false, debugLogging = false } = config;
const { app, mainWindow, protocol, isDev = false, debugLogging = false, electronPath = '/node_modules/electron/dist/Electron.app' } = config;

this.checkConfig(config);

this.config = { protocol, debugLogging, isDev };
this.config = { protocol, debugLogging, isDev, electronPath };
this.app = app;
this.mainWindow = mainWindow;

Expand Down Expand Up @@ -142,7 +144,7 @@ class Deeplink extends EventEmitter {
let infoPlist;

this.appPath = this.app.getAppPath();
this.electronPath = path.join(this.appPath, '/node_modules/electron/dist/Electron.app');
this.electronPath = path.join(this.appPath, this.config.electronPath);
this.infoPlistFile = path.join(this.electronPath, '/Contents/Info.plist');
this.infoPlistFileBak = path.join(this.electronPath, '/Contents/Info.deeplink');

Expand Down

0 comments on commit 6fe6924

Please sign in to comment.