1 | const { app, ipcMain } = require('electron'); |
||
2 | const path = require("path"); |
||
0 ignored issues
–
show
Unused Code
introduced
by
![]() |
|||
3 | const Window = require("./Window"); |
||
0 ignored issues
–
show
|
|||
4 | const AppMenu = require("./AppMenu"); |
||
0 ignored issues
–
show
|
|||
5 | const Store = require('electron-store'); |
||
0 ignored issues
–
show
|
|||
6 | const EventEmitter = require('events'); |
||
0 ignored issues
–
show
|
|||
7 | const SaveFile = require('./SaveFile'); |
||
0 ignored issues
–
show
|
|||
8 | |||
9 | /** |
||
10 | * App Singleton (Wrapper around electron app singleton var) |
||
11 | */ |
||
12 | module.exports = class App extends EventEmitter { |
||
13 | constructor() { |
||
14 | super(); |
||
15 | |||
16 | // Make Single Instance and ensure single instance |
||
17 | // if (app.requestSingleInstanceLock()) { |
||
18 | // this.quit(); |
||
19 | // return; |
||
20 | // } |
||
21 | //app.on('second-instance', this.onSecondInstance.bind(this)); |
||
22 | |||
23 | // Electron app var |
||
24 | this.app = app; |
||
25 | |||
26 | // Window |
||
27 | this.mainWindow = null; |
||
28 | |||
29 | // Is development or not |
||
30 | this.isDev = process.env.DEV |
||
31 | ? (process.env.DEV.trim() == "true") |
||
32 | : false; |
||
33 | |||
34 | // Adjust process working directory depending on dev enviroment or not |
||
35 | if (this.isDev) |
||
36 | process.chdir(path.join(__dirname, '../src')); |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() The variable
path seems to be never declared. If this is a global, consider adding a /** global: path */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. ![]() |
|||
37 | else |
||
38 | process.chdir(path.join(__dirname, '../dist/pokered-save-editor')); |
||
39 | |||
40 | this.store = new Store(); |
||
0 ignored issues
–
show
The variable
Store seems to be never declared. If this is a global, consider adding a /** global: Store */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. ![]() |
|||
41 | this.saveFile = new SaveFile(this); |
||
0 ignored issues
–
show
The variable
SaveFile seems to be never declared. If this is a global, consider adding a /** global: SaveFile */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. ![]() |
|||
42 | |||
43 | // App Icon |
||
44 | this.icon = 'assets/icons/512x512.png'; |
||
45 | |||
46 | // Set Name |
||
47 | app.setName("Pokered Save Editor"); |
||
48 | |||
49 | // App events to hook into for wrapper |
||
50 | app.on('ready', this.createWindow.bind(this)); |
||
51 | app.on('window-all-closed', this.quit.bind(this)); |
||
52 | |||
53 | ipcMain.on('ipcFrom', this.onIpcFrom.bind(this)); |
||
0 ignored issues
–
show
The variable
ipcMain seems to be never declared. If this is a global, consider adding a /** global: ipcMain */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. ![]() |
|||
54 | } |
||
55 | |||
56 | onIpcFrom(sender, event, ...args) { |
||
57 | this.emit(`ipcFrom-${event}`, ...args); |
||
58 | } |
||
59 | |||
60 | onSecondInstance(argv, cwd) { |
||
0 ignored issues
–
show
|
|||
61 | if (this.mainWindow) |
||
62 | this.mainWindow.reOpen(); |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
63 | } |
||
64 | |||
65 | createWindow() { |
||
66 | // Menu must be called around this time so it's placed here |
||
67 | this.menu = new AppMenu(this); |
||
0 ignored issues
–
show
The variable
AppMenu seems to be never declared. If this is a global, consider adding a /** global: AppMenu */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. ![]() |
|||
68 | this.mainWindow = new Window(this); |
||
0 ignored issues
–
show
The variable
Window seems to be never declared. If this is a global, consider adding a /** global: Window */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. ![]() |
|||
69 | } |
||
70 | |||
71 | quit() { |
||
72 | app.quit(); |
||
73 | } |
||
74 | } |
||
75 |