mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-05 22:19:46 -06:00
* refactor: makeLegacyContext -> getCtx * Fix tests & types * fix: failing tests * CI fixes
32 lines
876 B
TypeScript
32 lines
876 B
TypeScript
import os from 'os'
|
|
import { EventEmitter } from 'events'
|
|
import type { App } from 'electron'
|
|
|
|
import { makeDataContext } from '../makeDataContext'
|
|
import { makeGraphQLServer } from '../gui/makeGraphQLServer'
|
|
import { assertValidPlatform } from '@packages/types/src/platform'
|
|
import { DataContext, getCtx, setCtx } from '@packages/data-context'
|
|
|
|
export function runInternalServer (launchArgs, _internalOptions = { loadCachedProjects: true }, electronApp?: App) {
|
|
const bus = new EventEmitter()
|
|
const platform = os.platform()
|
|
|
|
assertValidPlatform(platform)
|
|
|
|
let ctx: DataContext
|
|
|
|
try {
|
|
ctx = getCtx()
|
|
} catch {
|
|
ctx = setCtx(makeDataContext(launchArgs))
|
|
}
|
|
|
|
// Initializing the data context, loading browsers, etc.
|
|
ctx.initializeData()
|
|
ctx.emitter.init()
|
|
|
|
const serverPortPromise = makeGraphQLServer(ctx)
|
|
|
|
return { ctx, bus, serverPortPromise }
|
|
}
|