(msg: IPCMessage)
| 20 | * Send an IPC message to a forked process. |
| 21 | */ |
| 22 | export async function send(msg: IPCMessage): Promise<void> { |
| 23 | const dir = ENV_PATHS.log; |
| 24 | await mkdirp(dir); |
| 25 | const logPath = resolve(dir, 'ipc.log'); |
| 26 | |
| 27 | debug('Sending %O IPC message to forked process (logs: %O)', msg.type, logPath); |
| 28 | |
| 29 | const fd = await open(logPath, 'a'); |
| 30 | const p = fork(process.argv[1], ['📡'], { stdio: ['ignore', fd, fd, 'ipc'] }); |
| 31 | |
| 32 | p.send(msg); |
| 33 | p.disconnect(); |
| 34 | p.unref(); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Receive and handle an IPC message. |
no test coverage detected