append the --no-sandbox when running with root user

This commit is contained in:
cnjack 2023-09-21 17:50:46 +08:00 committed by GitHub
parent 2360d502a4
commit 122dfbfe14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
import path from 'node:path' import path from 'node:path'
import fs from 'node:fs' import fs from 'node:fs'
import os from 'node:os'
import { createRequire } from 'node:module' import { createRequire } from 'node:module'
import { type ChildProcess, spawn } from 'node:child_process' import { type ChildProcess, spawn } from 'node:child_process'
@ -122,6 +123,10 @@ export function startElectron(root: string | undefined): ChildProcess {
const args: string[] = [] const args: string[] = []
if (os.userInfo().uid == 0 && isDev) {
args.push(`--no-sandbox`);
}
if (!!process.env.REMOTE_DEBUGGING_PORT && isDev) { if (!!process.env.REMOTE_DEBUGGING_PORT && isDev) {
args.push(`--remote-debugging-port=${process.env.REMOTE_DEBUGGING_PORT}`) args.push(`--remote-debugging-port=${process.env.REMOTE_DEBUGGING_PORT}`)
} }