Skip to content

Commit

Permalink
Build by env
Browse files Browse the repository at this point in the history
  • Loading branch information
abelogur committed Oct 16, 2018
1 parent de9595a commit dfebdbd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions main.ts
@@ -1,14 +1,19 @@
import {app, BrowserWindow} from 'electron';
import {Database} from './database/database';
import * as fs from 'fs';
const path = require('path');
const dbPath = path.resolve(process.resourcesPath, 'data.db');

const dbPathDev = path.resolve(__dirname, 'data.db');
const dbPathProd = path.resolve(process.resourcesPath, 'data.db');

class SchoolSectionsApp {

env: String;
mainWindow: BrowserWindow;

constructor() {
this.mainWindow = this.createWindow();
this.env = fs.existsSync(dbPathDev) ? 'dev' : 'prod';
this.connectionToDataBase()
}

Expand All @@ -22,13 +27,12 @@ class SchoolSectionsApp {

mainWindow.maximize();
mainWindow.loadURL(`file://${__dirname}/dist/index.html`);
mainWindow.webContents.openDevTools();

return mainWindow;
}

private connectionToDataBase() {
new Database(dbPath);
this.env === 'dev' ? new Database(dbPathDev) : new Database(dbPathProd);
}
}

Expand Down

0 comments on commit dfebdbd

Please sign in to comment.