Skip to content
Myr

ipc-send-pid.js

This file

Path

test/fixtures/ipc-send-pid.js

22 lines · 578 bytes · JavaScript

Last changed by

Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d

History of this file

Take it

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 1–4why, one step back
1#!/usr/bin/env node
2import process from 'node:process';3import {execa, sendMessage} from '../../index.js';4

Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d

lines 5–6why, one step back
5const isCleanup = process.argv[2] === 'true';
6const isDetached = process.argv[3] === 'true';

Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf

lines 7–8why, one step back
7const file = process.argv[4] === 'no-killable' ? 'no-killable.js' : 'forever.js';
8const options = {

Update dev dependencies (#1257)Sindre Sorhusbefore adoption5944b2d

lines 9–10why, one step back
9 cleanup: isCleanup,
10 detached: isDetached,

Add `nodeChildProcess` to subprocess promises and make the subprocess a normal promise (#1255)Sindre Sorhusbefore adoptionade74bf

lines 11–20why, one step back
11 ...(file === 'no-killable.js' && {
12 ipc: true,13 killSignal: 'SIGKILL',14 }),15};16const subprocess = execa(file, options);17if (options.ipc) {18 await subprocess.getOneMessage();19}20

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 21–22why, one step back
21await sendMessage(subprocess.pid);
22await subprocess;