Skip to content

Commit

Permalink
Merge branch 'main' into rxjs-remove-deprecated-code
Browse files Browse the repository at this point in the history
  • Loading branch information
paescuj committed Jun 24, 2023
2 parents 1a64097 + 744ece9 commit f910f88
Show file tree
Hide file tree
Showing 35 changed files with 4,781 additions and 12,611 deletions.
5 changes: 4 additions & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<!--
>> Before opening a new issue, please ensure there's no
>> existing issue with the same concern!
For bug reports, please provide the following information:
- Description: Clear and concise description of what the bug is
- Expected Behavior: What you expected to happen (instead)
- Expected Behavior: What you expected to happen
- Environment: At least the OS and version of "concurrently"
- Reproduction: A way to reproduce the issue
Expand Down
14 changes: 0 additions & 14 deletions .github/actions/setup-npm-cache/action.yml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/actions/setup-pnpm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See also https://github.com/actions/cache/blob/main/examples.md#node---npm

name: Setup pnpm
runs:
using: composite
steps:
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7

- name: Get pnpm store directory
id: pnpm-cache-dir
shell: bash
run: echo "dir=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
8 changes: 4 additions & 4 deletions .github/workflows/lint-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ jobs:
with:
node-version: 16

- name: Setup NPM cache
uses: ./.github/actions/setup-npm-cache
- name: Setup pnpm
uses: ./.github/actions/setup-pnpm

- name: Install dependencies
run: npm ci && npm install --global concurrently
run: pnpm install && pnpm add --global concurrently

- name: Lint & Format
run: concurrently --prefix none --group "npm:lint" "npm:format"
run: concurrently --prefix none --group "pnpm:lint" "pnpm:format"
46 changes: 46 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Release

on:
push:
tags:
- 'v*'

permissions:
contents: write

jobs:
gh-release:
name: Create GitHub Release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release create "$GITHUB_REF_NAME" --generate-notes

publish-npm:
name: Publish to NPM
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org

- name: Setup pnpm
uses: ./.github/actions/setup-pnpm

- name: Install dependencies
run: pnpm install

- name: Publish to NPM
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm publish --no-git-checks
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ jobs:
fail-fast: false
matrix:
node:
- 12
- 14
- 16
- 17
- 18
- 19
os:
- name: Ubuntu
version: ubuntu-latest
Expand All @@ -48,14 +48,14 @@ jobs:
with:
node-version: ${{ matrix.node }}

- name: Setup NPM cache
uses: ./.github/actions/setup-npm-cache
- name: Setup pnpm
uses: ./.github/actions/setup-pnpm

- name: Install dependencies
run: npm ci && npm install --global concurrently
run: pnpm install && pnpm add --global concurrently

- name: Build & Test
run: concurrently --prefix none --group "npm:build" "npm:test"
run: concurrently --prefix none --group "pnpm:build" "pnpm:test"

- name: Submit coverage
uses: coverallsapp/github-action@master
Expand Down
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

./node_modules/.bin/lint-staged
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
coverage
pnpm-lock.yaml
10 changes: 3 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,15 @@ updated.

## Code Format & Linting

Code format and lint checks are performed locally when committing to ensure the changes align with the configured rules of this repository. This happens with the help of the tools [simple-git-hooks](https://github.com/toplenboren/simple-git-hooks) and [lint-staged](https://github.com/okonet/lint-staged) which are automatically installed and configured on `npm install` (no further steps required).
Code format and lint checks are performed locally when committing to ensure the changes align with the configured rules of this repository. This happens with the help of the tools [simple-git-hooks](https://github.com/toplenboren/simple-git-hooks) and [lint-staged](https://github.com/okonet/lint-staged) which are automatically installed and configured on `pnpm install` (no further steps required).

In case of problems, a corresponding message is displayed in your terminal.
Please fix them and then run the commit command again.

## Test

Tests can be run with the command:
Tests can be executed with the following command:

```bash
npm test
pnpm test
```

## Release

Use [np](https://www.npmjs.com/package/np) to create a new release.
33 changes: 17 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Latest Release](https://img.shields.io/github/v/release/open-cli-tools/concurrently?label=Release)](https://github.com/open-cli-tools/concurrently/releases)
[![License](https://img.shields.io/github/license/open-cli-tools/concurrently?label=License)](https://github.com/open-cli-tools/concurrently/blob/main/LICENSE)
[![Weekly Downloads on NPM](https://img.shields.io/npm/dw/concurrently?label=Downloads&logo=npm)](https://www.npmjs.com/package/concurrently)
[![CI Status](https://img.shields.io/github/workflow/status/open-cli-tools/concurrently/CI?label=CI&logo=github)](https://github.com/open-cli-tools/concurrently/actions/workflows/ci.yml)
[![CI Status](https://img.shields.io/github/actions/workflow/status/open-cli-tools/concurrently/test.yml?label=CI&logo=github)](https://github.com/open-cli-tools/concurrently/actions/workflows/test.yml)
[![Coverage Status](https://img.shields.io/coveralls/github/open-cli-tools/concurrently/main?label=Coverage&logo=coveralls)](https://coveralls.io/github/open-cli-tools/concurrently?branch=main)

Run multiple commands concurrently.
Expand All @@ -15,7 +15,7 @@ Like `npm run watch-js & npm run watch-less` but better.

- [concurrently](#concurrently)
- [Why](#why)
- [Install](#install)
- [Installation](#installation)
- [Usage](#usage)
- [API](#api)
- [`concurrently(commands[, options])`](#concurrentlycommands-options)
Expand All @@ -25,7 +25,7 @@ Like `npm run watch-js & npm run watch-less` but better.

## Why

I like [task automation with npm](https://github.com/substack/blog/blob/master/npm_run.markdown)
I like [task automation with npm](https://web.archive.org/web/20220531064025/https://github.com/substack/blog/blob/master/npm_run.markdown)
but the usual way to run multiple commands concurrently is
`npm run watch-js & npm run watch-css`. That's fine but it's hard to keep
on track of different outputs. Also if one process fails, others still keep running
Expand All @@ -41,25 +41,24 @@ tired of opening terminals and made **concurrently**.
- With `--kill-others` switch, all commands are killed if one dies
- Spawns commands with [spawn-command](https://github.com/mmalecki/spawn-command)

## Install
## Installation

The tool is written in Node.js, but you can use it to run **any** commands.

```bash
npm install -g concurrently
```
**concurrently** can be installed in the global scope (if you'd like to have it available and use it on the whole system) or locally for a specific package (for example if you'd like to use it in the `scripts` section of your package):

or if you are using it from npm scripts:
| | npm | Yarn | pnpm | Bun |
| ----------- | ----------------------- | ------------------------------ | -------------------------- | ------------------------- |
| **Global** | `npm i -g concurrently` | `yarn global add concurrently` | `pnpm add -g concurrently` | `bun add -g concurrently` |
| **Local**\* | `npm i -D concurrently` | `yarn add -D concurrently` | `pnpm add -D concurrently` | `bun add -d concurrently` |

```bash
npm install concurrently --save-dev
```
<sub>\* It's recommended to add **concurrently** to `devDependencies` as it's usually used for developing purposes. Please adjust the command if this doesn't apply in your case.</sub>

## Usage

> **Note**
> The `concurrently` command is now also available under the shorthand alias `conc`.
The tool is written in Node.js, but you can use it to run **any** commands.

Remember to surround separate commands with quotes:

```bash
Expand Down Expand Up @@ -220,6 +219,8 @@ Killing other processes
-k, --kill-others Kill other processes if one exits or dies.[boolean]
--kill-others-on-fail Kill other processes if one exits with non zero
status code. [boolean]
--kill-signal Signal to send to other processes if one exits or dies.
(SIGTERM/SIGKILL, defaults to SIGTERM) [string]
Restarting
--restart-tries How many times a process that died should restart.
Expand Down Expand Up @@ -339,7 +340,7 @@ For more details, visit https://github.com/open-cli-tools/concurrently
Prefix colors specified per-command take precedence over this list.
- `prefixLength`: how many characters to show when prefixing with `command`. Default: `10`
- `raw`: whether raw mode should be used, meaning strictly process output will
be logged, without any prefixes, coloring or extra stuff.
be logged, without any prefixes, coloring or extra stuff. Can be overriden per command.
- `successCondition`: the condition to consider the run was successful.
If `first`, only the first process to exit will make up the success of the run; if `last`, the last process that exits will determine whether the run succeeds.
Anything else means all processes should exit successfully.
Expand Down Expand Up @@ -428,6 +429,6 @@ It contains the following properties:
So _null_ means the process didn't terminate normally. This will make **concurrently**
to return non-zero exit code too.

- Does this work with the npm-replacements [yarn](https://github.com/yarnpkg/yarn) or [pnpm](https://pnpm.js.org/)?
- Does this work with the npm-replacements [yarn](https://github.com/yarnpkg/yarn), [pnpm](https://pnpm.js.org/), or [Bun](https://bun.sh/)?

Yes! In all examples above, you may replace "`npm`" with "`yarn`" or "`pnpm`".
Yes! In all examples above, you may replace "`npm`" with "`yarn`", "`pnpm`", or "`bun`".
11 changes: 7 additions & 4 deletions bin/concurrently.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import { map } from 'rxjs/operators';
import stringArgv from 'string-argv';

const isWindows = process.platform === 'win32';
const createKillMessage = (prefix: string, signal: 'SIGTERM' | 'SIGINT') => {
const createKillMessage = (prefix: string, signal: 'SIGTERM' | 'SIGINT' | string) => {
const map: Record<string, string | number> = {
SIGTERM: isWindows ? 1 : '(SIGTERM|143)',
// Could theoretically be anything (e.g. 0) if process has SIGINT handler
SIGINT: isWindows ? '(3221225786|0)' : '(SIGINT|130|0)',
};
return new RegExp(escapeRegExp(prefix) + ' exited with code ' + map[signal]);
return new RegExp(escapeRegExp(prefix) + ' exited with code ' + (map[signal] ?? signal));
};

let tmpDir: string;
Expand All @@ -37,7 +37,7 @@ beforeAll(async () => {
afterAll(() => {
// Remove the temporary directory where 'concurrently' was stored
if (tmpDir) {
fs.rmdirSync(tmpDir, { recursive: true });
fs.rmSync(tmpDir, { recursive: true });
}
});

Expand Down Expand Up @@ -194,7 +194,10 @@ describe('exiting conditions', () => {
? // '^C' is echoed by read-echo.js (also happens without the wrapper)
'[0] ^Cnode fixtures/read-echo.js'
: '[0] node fixtures/read-echo.js',
'SIGINT'
// TODO: Flappy value due to race condition, sometimes killed by concurrently (exit code 1),
// sometimes terminated on its own (exit code 0).
// Related issue: https://github.com/open-cli-tools/concurrently/issues/283
isWindows ? '(3221225786|0|1)' : 'SIGINT'
)
)
);
Expand Down
10 changes: 9 additions & 1 deletion bin/concurrently.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ const args = yargs(argsBeforeSep)
describe: 'Kill other processes if one exits with non zero status code.',
type: 'boolean',
},
'kill-signal': {
alias: 'ks',
describe:
'Signal to send to other processes if one exits or dies. (SIGTERM/SIGKILL, defaults to SIGTERM)',
type: 'string',
default: defaults.killSignal,
},

// Prefix
prefix: {
Expand Down Expand Up @@ -185,7 +192,7 @@ const args = yargs(argsBeforeSep)
)
.group(['p', 'c', 'l', 't'], 'Prefix styling')
.group(['i', 'default-input-target'], 'Input handling')
.group(['k', 'kill-others-on-fail'], 'Killing other processes')
.group(['k', 'kill-others-on-fail', 'kill-signal'], 'Killing other processes')
.group(['restart-tries', 'restart-after'], 'Restarting')
.epilogue(epilogue)
.parseSync();
Expand All @@ -208,6 +215,7 @@ concurrently(
: args.killOthersOnFail
? ['failure']
: [],
killSignal: args.killSignal,
maxProcesses: args.maxProcesses,
raw: args.raw,
hide: args.hide.split(','),
Expand Down
12 changes: 4 additions & 8 deletions bin/fixtures/sleep.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@

/* eslint-disable no-console */

async function run(s) {
await new Promise((resolve) => setTimeout(resolve, s * 1000));
}

const s = process.argv[2];
if (!s || isNaN(s) || process.argv.length > 3) {
const seconds = process.argv[2];
if (!seconds || isNaN(seconds) || process.argv.length > 3) {
// Mimic behavior from native 'sleep' command
console.error(`usage: sleep seconds`);
console.error('usage: sleep seconds');
process.exit(1);
}
run(s);
await new Promise((resolve) => setTimeout(resolve, seconds * 1000));
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* While in local development, make sure you've run `npm run build` first.
* While in local development, make sure you've run `pnpm run build` first.
*/

// eslint-disable-next-line @typescript-eslint/no-var-requires
Expand Down
2 changes: 1 addition & 1 deletion index.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* While in local development, make sure you've run `npm run build` first.
* While in local development, make sure you've run `pnpm run build` first.
*/

import concurrently from './dist/src/index.js';
Expand Down
Loading

0 comments on commit f910f88

Please sign in to comment.