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
7.15k stars 234 forks source link

Inter-Process Communication #498

Closed gustavohenke closed 3 months ago

gustavohenke commented 3 months ago

This PR implements basic inter-process communication (IPC), which is an API-only feature - not available through CLI.

Command has the following new fields/methods:

The caller must set the ipc property when calling concurrently(). It sets the number of the file descriptor on which to set up the IPC channel.

Example usage:

const { commands } = concurrently([{ command: 'echo foo', ipc: 3 }]);
commands[0].send({ hello: 'world' })
commands[0].messages.incoming.subscribe(({ message }) => {
    console.log('command 0 sent this:', message);
});

With this PR I also realise that the README is no longer a good option for documentation. We need to expand it into a website...

coveralls commented 3 months ago

Coverage Status

coverage: 99.178% (+0.03%) from 99.144% when pulling 14b318a3a9e6ceda66bd5abb9b3877e6f94ba1b7 on ipc into 23f97ac412f390a9913f96814da1f4070704d955 on main.

gustavohenke commented 2 months ago

🚢 This is now available in v9.0.0! https://github.com/open-cli-tools/concurrently/releases/tag/v9.0.0

studiosciences commented 2 months ago

This is great! Thx @gustavohenke.

I created a simple "waitForStartMessage.js" script, so that I could delay a process until our Orval code generation process is setup.

    {
      command: `node ${__dirname}/waitForStartMessage.js && yarn start`,
      name: "ui",
      ipc: 3,
    },