Skip to content

Commit

Permalink
fix(packages/core): remove electron-context-menu dependence
Browse files Browse the repository at this point in the history
also electron-squirrel-starutp
Fixes kubernetes-sigs#3064

the former is causing problems with Edge
Fixes kubernetes-sigs#3014
  • Loading branch information
starpit committed Oct 21, 2019
1 parent b9ddcd1 commit 628a936
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 196 deletions.
150 changes: 5 additions & 145 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
"colors": "1.4.0",
"columnify": "1.5.4",
"debug": "4.1.1",
"electron-context-menu": "0.15.0",
"electron-squirrel-startup": "1.0.0",
"extract-zip": "1.6.7",
"fs-extra": "8.1.0",
"marked": "^0.7.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const main = async (argv: string[], env = process.env, execOptions?: Exec
const { argv: strippedArgv, subwindowPlease, subwindowPrefs } = getCommand(argv)
initElectron(
strippedArgv,
{ isRunningHeadless, forceUI },
{ isRunningHeadless },
!!(env.subwindowPlease || subwindowPlease),
env.subwindowPrefs
? typeof env.subwindowPrefs === 'string'
Expand Down
50 changes: 2 additions & 48 deletions packages/core/src/main/spawn-electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,6 @@ export function createWindow(
// but this doesn't render the inset window buttons
// see https://github.com/electron/electron/issues/10243
promise.then(async () => {
try {
require('electron-context-menu')()
} catch (err) {
debug('not ready for graphics, still', err)
return
}

const {
theme,
env
Expand Down Expand Up @@ -434,52 +427,13 @@ export const getCommand = (argv: string[]): Command => {
*/
export async function initElectron(
command: string[] = [],
{ isRunningHeadless = false, forceUI = false } = {},
{ isRunningHeadless = false } = {},
subwindowPlease?: boolean,
subwindowPrefs?: ISubwindowPrefs
) {
debug('initElectron', command, subwindowPlease, subwindowPrefs)

let promise: Promise<void>

// handle squirrel install and update events
try {
if (require('electron-squirrel-startup')) return
} catch (err) {
debug('electron components not directly installed')

/**
* We seem to be running with a headless.zip build; now determine
* the best course of action
*/
const maybeSpawnGraphics = async () => {
if (!forceUI && !app) {
const { initHeadless } = await import('./headless')
await initHeadless(process.argv, true)
}
const colors = await import('colors/safe')
console.log(colors.red('Graphical components are not installed.'))
process.exit(126)
}

try {
// then this is probably an unrelated package.json file
// _location will only be present for npm install'd assets
// and the name is there to match our top-level package.json
await maybeSpawnGraphics()
} catch (err) {
// we couldn't find ../package.json; we're probably using a
// headless.zip installation
debug(err)

console.log('Graphical components are not installed.')
process.exit(126)
}
}

if (promise) {
return promise
} else if (!app) {
if (!app) {
debug('loading electron')
const Electron = await import('electron')
app = Electron.app
Expand Down

0 comments on commit 628a936

Please sign in to comment.