Skip to content

Commit

Permalink
Fix path resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
exentrich committed Jun 10, 2024
1 parent 7b12a6b commit 3705273
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
9 changes: 5 additions & 4 deletions build/version.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'fs';
import fs from 'fs'
import { resolve } from 'path'

const version = JSON.parse(fs.readFileSync(new URL('../webapp/package.json', import.meta.url).pathname, 'utf-8')).version;
const packageContent = fs.readFileSync(new URL('../package.json', import.meta.url).pathname, 'utf-8');
fs.writeFileSync(new URL('../package.json', import.meta.url).pathname, packageContent.replace(/version": "(.*)"/i, `version": "${version}"`), 'utf-8');
const version = JSON.parse(fs.readFileSync(resolve(import.meta.dirname, '../webapp/package.json'), 'utf-8')).version;
const packageContent = fs.readFileSync(resolve(import.meta.dirname, '../package.json'), 'utf-8');
fs.writeFileSync(resolve(import.meta.dirname, '../package.json'), packageContent.replace(/version": "(.*)"/i, `version": "${version}"`), 'utf-8');
3 changes: 2 additions & 1 deletion src/webview/index.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { app } from 'electron'
import { resolve } from 'path'

const onWillAttachWebview = (_, webPreferences) => {
//preload highligh script for all webview's
webPreferences.preload = new URL('./highlight.js', import.meta.url).pathname
webPreferences.preload = resolve(import.meta.dirname, './highlight.js')
}

export default function() {
Expand Down
3 changes: 2 additions & 1 deletion src/window.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BrowserWindow, nativeTheme } from 'electron'
import isDev from 'electron-is-dev'
import windowState from 'electron-window-state'
import { resolve } from 'path'

class Window {
window = null
Expand Down Expand Up @@ -62,7 +63,7 @@ class Window {
if (isDev)
this.window.loadURL('http://localhost:2000')
else
this.window.loadFile(new URL('../webapp/dist/electron/prod/index.html', import.meta.url).pathname)
this.window.loadFile(resolve(import.meta.dirname, '../webapp/dist/electron/prod/index.html'))

//events
this.window.once('ready-to-show', this.window.show)
Expand Down

0 comments on commit 3705273

Please sign in to comment.