Skip to content

Commit

Permalink
feat: Support Electron.NativeImage icon argument (#7)
Browse files Browse the repository at this point in the history
Re-implementation of #198
  • Loading branch information
amaury1093 authored Mar 24, 2019
1 parent 2cc6885 commit 03d67f3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,17 @@ class Menubar extends EventEmitter {
app.dock.hide();
}

let iconPath =
let trayImage =
this.options.icon || path.join(this.options.dir, 'IconTemplate.png');
if (!fs.existsSync(iconPath)) {
iconPath = path.join(__dirname, 'example', 'IconTemplate.png'); // Default cat icon
if (typeof trayImage === 'string' && !fs.existsSync(trayImage)) {
trayImage = path.join(__dirname, 'example', 'IconTemplate.png'); // Default cat icon
}

const defaultClickEvent = this.options.showOnRightClick
? 'right-click'
: 'click';

this.tray = this.options.tray || new Tray(iconPath);
this.tray = this.options.tray || new Tray(trayImage);
// Type guards for TS not to complain
if (!this.tray) {
throw new Error('Tray has been initialized above');
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface Options {
* the end of the name, so icon.png and icon@2x.png and Electron will
* automatically use your @2x version on retina screens.
*/
icon?: string;
icon?: string | Electron.NativeImage;
/**
* The html to load for the pop up window.
*/
Expand Down

0 comments on commit 03d67f3

Please # to comment.