Skip to content

Commit c491c48

Browse files
committed
refactor/ replace deprecated url.format with URL WHATWG API
1 parent 61bc2a9 commit c491c48

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

app/main.ts

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
import { app, BrowserWindow, screen } from 'electron';
1+
import {app, BrowserWindow, screen} from 'electron';
22
import * as path from 'path';
33
import * as fs from 'fs';
4-
import * as url from 'url';
54

65
let win: BrowserWindow = null;
76
const args = process.argv.slice(1),
87
serve = args.some(val => val === '--serve');
98

109
function createWindow(): BrowserWindow {
1110

12-
const electronScreen = screen;
13-
const size = electronScreen.getPrimaryDisplay().workAreaSize;
11+
const size = screen.getPrimaryDisplay().workAreaSize;
1412

1513
// Create the browser window.
1614
win = new BrowserWindow({
@@ -20,7 +18,7 @@ function createWindow(): BrowserWindow {
2018
height: size.height,
2119
webPreferences: {
2220
nodeIntegration: true,
23-
allowRunningInsecureContent: (serve) ? true : false,
21+
allowRunningInsecureContent: (serve),
2422
contextIsolation: false, // false if you want to run e2e test with Spectron
2523
},
2624
});
@@ -40,11 +38,8 @@ function createWindow(): BrowserWindow {
4038
pathIndex = '../dist/index.html';
4139
}
4240

43-
win.loadURL(url.format({
44-
pathname: path.join(__dirname, pathIndex),
45-
protocol: 'file:',
46-
slashes: true
47-
}));
41+
const url = new URL(path.join('file:', __dirname, pathIndex));
42+
win.loadURL(url.href);
4843
}
4944

5045
// Emitted when the window is closed.

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"webdriver-manager": "12.1.8"
101101
},
102102
"engines": {
103-
"node": ">=14.0.0"
103+
"node": ">= 14.15.0"
104104
},
105105
"browserslist": [
106106
"chrome 100"

0 commit comments

Comments
 (0)