Skip to content

Commit

Permalink
feat: build that thing
Browse files Browse the repository at this point in the history
schagga schagga

fix #11
ref #10
  • Loading branch information
Xiphe committed Apr 17, 2020
1 parent 2ae53ae commit 6c64bbf
Show file tree
Hide file tree
Showing 9 changed files with 4,809 additions and 1,488 deletions.
6 changes: 0 additions & 6 deletions main.js

This file was deleted.

14 changes: 11 additions & 3 deletions main/moneymoney/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { IpcMain } from 'electron';
import { join } from 'path';
import { exec } from 'child_process';
import { parse } from 'plist';
import osascript from './osascript';

const scriptsDir = __dirname.includes('/app.asar/')
? join(process.resourcesPath, 'scripts')
: join((require as any).main.filename, '../../main/moneymoney');

function isDbLocked(err: any) {
return err.stderr && err.stderr.includes('Locked database. (-2720)');
}
Expand Down Expand Up @@ -44,7 +49,7 @@ export default function moneymoneyHandlers(ipcMain: IpcMain) {

try {
await osascript(
__dirname + '/exportTransactions.applescript',
join(scriptsDir, 'exportTransactions.applescript'),
accountNumber,
new Date().toLocaleDateString(),
);
Expand All @@ -60,7 +65,7 @@ export default function moneymoneyHandlers(ipcMain: IpcMain) {
'MM_EXPORT_ACCOUNTS',
withRetry(async () => {
const accounts = parse(
await osascript(__dirname + '/exportAccounts.applescript'),
await osascript(join(scriptsDir, 'exportAccounts.applescript')),
);
if (!Array.isArray(accounts)) {
throw new Error('Unexpectedly got non-array as accounts');
Expand Down Expand Up @@ -92,7 +97,10 @@ export default function moneymoneyHandlers(ipcMain: IpcMain) {
'MM_EXPORT_TRANSACTIONS',
withRetry(async (_, ...args) => {
return parse(
await osascript(__dirname + '/exportTransactions.applescript', ...args),
await osascript(
join(scriptsDir, 'exportTransactions.applescript'),
...args,
),
);
}),
);
Expand Down
2 changes: 1 addition & 1 deletion main/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"module": "commonjs",
"noEmit": false,
"outDir": "../dist"
"outDir": "./dist"
},
"include": ["./*.ts"]
}
4 changes: 2 additions & 2 deletions main/windowManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BrowserWindow, IpcMain, WebContents } from 'electron';
import { join } from 'path';

export type WindowManager = ReturnType<typeof createWindowManager>;
export default function createWindowManager(ipcMain: IpcMain) {
Expand Down Expand Up @@ -39,7 +40,6 @@ export default function createWindowManager(ipcMain: IpcMain) {
const win = new BrowserWindow({
width: 800,
height: 600,
vibrancy: 'sidebar',
webPreferences: {
nodeIntegration: true,
},
Expand All @@ -57,7 +57,7 @@ export default function createWindowManager(ipcMain: IpcMain) {
win.loadURL(SERVER_URL);
win.webContents.openDevTools();
} else {
win.loadFile('./build/index.html');
win.loadFile(join(__dirname, '../../build/index.html'));
}

if (file) {
Expand Down
Loading

0 comments on commit 6c64bbf

Please sign in to comment.