aboutsummaryrefslogtreecommitdiff
path: root/src/index.js
blob: 9fe7610741e1de8c09044df1715b93269aecf78d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const fs = require("fs");
const path = require("path");
const { app, dialog, ipcMain, BrowserWindow } = require("electron");

const Emitter = require("events");
const events = new Emitter();

const utils = require("./utils");
const cli = require("./cli");

function start() {
	win = new BrowserWindow({
		width: 500,
		height: 115,
		show: false,
		title: "Viper",
		webPreferences: {
			nodeIntegration: true,
			contextIsolation: false,
		},
	}); win.openDevTools()

	win.removeMenu();
	win.loadFile(__dirname + "/app/index.html");
	win.webContents.once("dom-ready", () => {win.show()});

	ipcMain.on("setpath", (event) => {utils.setpath(win)})
}

ipcMain.on("setpathcli", (event) => {utils.setpath()})
ipcMain.on("update", (event) => {utils.update()})

process.chdir(app.getPath("appData"));

if (cli.hasArgs()) {
	cli.init();
} else {
	app.on("ready", () => {
		app.setPath("userData", path.join(app.getPath("cache"), app.name));
		start();
	})
}