Skip to content

Commit 8bd3a80

Browse files
committed
Improve app config reader.
1 parent e17c5c8 commit 8bd3a80

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src.mainproc/lib/conf.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
import * as fs from 'fs';
3+
import * as path from 'path';
4+
import { app } from 'electron';
5+
6+
7+
8+
export const appConfig = JSON.parse(
9+
fs.readFileSync(path.join(app.getAppPath(), 'config/app-config.json')).toString());

src.mainproc/main.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11

22
// Modules to control application life and create native browser window
3-
import * as fs from 'fs';
43
import * as url from 'url';
54
import * as path from 'path';
65
import { app, protocol } from 'electron';
7-
import { createMainWindow } from './windows/MainWindow';
86

97

8+
// Window
9+
10+
import { appConfig } from './lib/conf';
11+
import { createMainWindow } from './windows/MainWindow';
12+
1013

1114
// IPC events
1215

13-
// tslint:disable-next-line:no-var-requires
14-
require('./ipc/app');
15-
// tslint:disable-next-line:no-var-requires
16-
require('./ipc/views.Home');
16+
import './ipc/app';
17+
import './ipc/views.Home';
1718

1819

1920
// Read the application config.
2021
// tslint:disable-next-line:no-console
21-
console.log('app config: ' + fs.readFileSync(path.join(app.getAppPath(), 'config/app-config.json')).toString());
22+
console.log('app config: ' + JSON.stringify(appConfig, null, 2));
2223

2324

2425
// App lifecycle events.

0 commit comments

Comments
 (0)