Skip to content

Commit

Permalink
optimize for windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
Saul-Mirone committed Feb 11, 2021
1 parent 675f3b6 commit 7d48c33
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"@testing-library/user-event": "^12.6.2",
"@type-config/strict": "^1.1.1",
"@types/better-sqlite3": "^5.4.1",
"@types/fs-extra": "^9.0.6",
"@types/history": "^4.7.7",
"@types/jest": "^26.0.10",
"@types/lodash": "^4.14.168",
Expand Down Expand Up @@ -184,6 +185,7 @@
"electron-log": "^4.2.4",
"electron-squirrel-startup": "^1.0.0",
"electron-updater": "^4.3.4",
"fs-extra": "^8.1.0",
"history": "^4.7.2",
"lodash": "^4.17.20",
"luxon": "^1.25.0",
Expand Down
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { ChannelMain } from './channel/main';
import { MenuBuilder } from './menu';
import { Model } from './model';

if (require('electron-squirrel-startup')) app.quit();

if (process.env.NODE_ENV === 'production') {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const sourceMapSupport = require('source-map-support');
Expand Down
5 changes: 4 additions & 1 deletion src/model/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Database from 'better-sqlite3';
import { app } from 'electron';
import { ensureDirSync } from 'fs-extra';
import path from 'path';
import { getPost } from './getPost';
import { getPostList, GetPostListOptions } from './getPostList';
Expand All @@ -18,7 +19,9 @@ export class Model {

constructor() {
// const dbPath = ':memory:';
const dbPath = path.resolve(app.getPath('appData'), 'homura', '0.0.2', 'database.sqlite');
const dbDir = path.resolve(app.getPath('appData'), 'homura', '0.0.2');
ensureDirSync(dbDir);
const dbPath = path.resolve(dbDir, 'database.sqlite');
this.sqlite = new Database(dbPath, { verbose: console.log });
this.initialize();
}
Expand Down
4 changes: 3 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2479,7 +2479,7 @@ __metadata:
languageName: node
linkType: hard

"@types/fs-extra@npm:^9.0.1":
"@types/fs-extra@npm:^9.0.1, @types/fs-extra@npm:^9.0.6":
version: 9.0.6
resolution: "@types/fs-extra@npm:9.0.6::__archiveUrl=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Ffs-extra%2Fdownload%2F%40types%2Ffs-extra-9.0.6.tgz"
dependencies:
Expand Down Expand Up @@ -8663,6 +8663,7 @@ fsevents@^1.2.7:
"@testing-library/user-event": ^12.6.2
"@type-config/strict": ^1.1.1
"@types/better-sqlite3": ^5.4.1
"@types/fs-extra": ^9.0.6
"@types/history": ^4.7.7
"@types/jest": ^26.0.10
"@types/lodash": ^4.14.168
Expand Down Expand Up @@ -8723,6 +8724,7 @@ fsevents@^1.2.7:
eslint-plugin-testing-library: ^3.10.0
file-loader: ^6.0.0
fork-ts-checker-webpack-plugin: ^6.1.0
fs-extra: ^8.1.0
history: ^4.7.2
husky: ^4.2.5
identity-obj-proxy: ^3.0.0
Expand Down

0 comments on commit 7d48c33

Please sign in to comment.