Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/src/editor-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ async function startEditorUnlocked(options: StartEditorOptions): Promise<StartEd
PASCAL_DATA_DIR: options.paths.data,
PASCAL_INSTANCE_ID: instanceId,
PASCAL_RUNTIME_VERSION: runtime.version,
MINT_PASCAL_HOST_ORIGIN: state.url,
MINT_PASCAL_HOST_ORIGIN: process.env.MINT_PASCAL_HOST_ORIGIN || state.url,
}
const nodeBinary = process.env.PASCAL_NODE_BINARY || 'node'
if (!options.foreground) await rotateEditorLog(options.paths.editorLog)
Expand Down
23 changes: 23 additions & 0 deletions packages/cli/src/runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,25 @@ describe('managed runtime', () => {
expect(await Bun.file(paths.database).text()).toBe('persistent')
})

test('preserves a configured Mint host origin in the editor process', async () => {
const root = await temporaryRoot()
const source = await fakeRuntime(root, '1.2.3')
const paths = resolvePascalPaths({ PASCAL_HOME: path.join(root, 'home') })
const previousMintOrigin = process.env.MINT_PASCAL_HOST_ORIGIN
process.env.MINT_PASCAL_HOST_ORIGIN = 'https://pascal.example.com'

try {
const started = await startEditor({ paths, sourceDirectory: source })
const response = await fetch(`http://127.0.0.1:${started.state.port}/mint-origin`)

expect(await response.text()).toBe('https://pascal.example.com')
} finally {
await stopEditor(paths)
if (previousMintOrigin === undefined) delete process.env.MINT_PASCAL_HOST_ORIGIN
else process.env.MINT_PASCAL_HOST_ORIGIN = previousMintOrigin
}
})

test('serializes concurrent starts into one managed editor', async () => {
const root = await temporaryRoot()
const source = await fakeRuntime(root, '1.2.3')
Expand Down Expand Up @@ -339,6 +358,10 @@ const server = http.createServer((request, response) => {
}))
return
}
if (request.url === '/mint-origin') {
response.end(process.env.MINT_PASCAL_HOST_ORIGIN ?? '')
return
}
response.end('{}')
})
server.listen(Number(process.env.PORT), process.env.HOSTNAME)
Expand Down