open-cli-tools / concurrently

Run commands concurrently. Like `npm run watch-js & npm run watch-less` but better.
https://www.npmjs.com/package/concurrently
MIT License
6.98k stars 227 forks source link

Allow commands IPC #465

Closed odeadglaz closed 2 weeks ago

odeadglaz commented 6 months ago

Hey 👋

Currently when spawning commands via concurrently, you cannot send messages from spawned process to top process due to the fact that the 'spwanOptions' won't allow it.

It might be useful to allow consumers to configure this in order to allow ipc and create communication in between.

If this something that make sense for you, would love to contribute it 👍

Example of what potentially I would want:

// test.ts
  const concurrency = concurrently([
      { name: 'Child Process', command: 'ts-node ./test2.ts'  },
  ], {
      killOthers: ['failure'],
  });
  const [subProcess] = concurrency.commands;

  subProcess.process?.on('message', (data) => {
      console.log('Sub process message:', data);
  });

 subProcess.process?.send({ parent: true });
//test2.ts
process.send?.({ child: true });

process.on('message', (msg) => {
    console.log('Message from parent:', msg);
});
gustavohenke commented 6 months ago

Great suggestion, let's add it! 😄

odeadglaz commented 6 months ago

Glad to hear, I can attach it to my open PR and resolve the two issues at once 🌮

odeadglaz commented 6 months ago

I tried adding it to the above mentioned PR, altho failed due to this issue. Do you plan to drop support for Node@16 over next major ? If so It won't be an issue rather just delaying this one.

gustavohenke commented 6 months ago

Maybe, it's not in LTS anymore. But each feature in its own PR, please