Skip to content

Commit 7f4f240

Browse files
committed
fix: use module.createRequire
1 parent e5d6504 commit 7f4f240

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/infra/chromium-path-provider.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,23 @@ import fs from 'fs'
33
import os from 'os'
44
import path from 'path'
55
import { Alert } from '@/infra/alert'
6-
// eslint-disable-next-line @typescript-eslint/no-require-imports
6+
import { createRequire } from 'module'
7+
8+
const require = createRequire(import.meta.url);
79
const download: (arg: Record<string, unknown>) => Promise<string> = require('download-chromium')
810

911
export type ChromiumProviderFunc = () => Promise<string | undefined>
1012

1113
const selectFromLocalTitle = '选择本地Chromium'
1214

13-
const defaultChromiumPath = {
14-
osx: [`${os.homedir()}/Applications/Google Chrome.app`, '/Applications/Google Chrome.app'],
15-
win: ['C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe'],
16-
}
17-
1815
const downloadFromInternetTitle = '帮我下载Chromium'
1916

2017
export class ChromiumPathProvider {
18+
static defaultChromiumPath = {
19+
osx: [`${os.homedir()}/Applications/Google Chrome.app`, '/Applications/Google Chrome.app'],
20+
win: ['C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe'],
21+
}
22+
2123
static lookupExecutableFromMacApp = (path?: string) => {
2224
if (path === undefined) return
2325

0 commit comments

Comments
 (0)