Skip to content
Source
Sign inSign up
samwillis/neon-realtime-electric
Open History to see the last commit

dev-function.mjs

25 lines648 Bytes

1import { spawn } from 'node:child_process'
2​
3// Host overrides and credentials are inherited from ignored local configuration.
4const profile = process.env.NEON_CLI_PROFILE
5const child = spawn(
6 'neon',
7 [
8 ...(profile ? ['--profile', profile] : []),
9 'dev',
10 '--source',
11 'apps/function/src/index.ts',
12 '--port',
13 '4327',
14 ],
15 { stdio: 'inherit', env: process.env }
17process.once('SIGINT', () => child.kill('SIGINT'))
18process.once('SIGTERM', () => child.kill('SIGTERM'))
19child.once('error', (error) => {
20 console.error(error.message)
21 process.exitCode = 1
22})
23child.once('exit', (code) => {
24 process.exitCode = code ?? 1
25})