Skip to content

Commit

Permalink
fix(CLI): support parallel option (#9)
Browse files Browse the repository at this point in the history
* fix(CLI): support parallel option

* chore: update dependencies
  • Loading branch information
wellwelwel authored Feb 18, 2024
1 parent 74becbc commit f32d20a
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 15 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ A flexible and easy-to-use **Test Runner** for [Node][node-version-url], [Bun][b

---

```bash
npx poku --include='test/unit,test/integration'
```

<img src="./.github/assets/readme/screen-recording-2024-02-17-at-23.38.06.gif" width="360">

---

## Install

### **Node.js**
Expand Down Expand Up @@ -247,6 +255,8 @@ FILTER='unit' npx poku --include='...'

Determines the mode of test execution across **sequential** or **parallel** modes.

- **in-code**

```ts
/**
* @default
Expand All @@ -269,11 +279,23 @@ poku(['...'], {
});
```

- **CLI**

> _Since **1.2.0**_
```bash
# Parallel mode

npx poku --include='...' --parallel
```

---

#### `exclude: RexExp | RexExp[]`

> Exclude by path using Regex to match only the files that should be performed.
>
> _Since **1.2.0**_
- **in-code**:

Expand Down
10 changes: 6 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"test:node": "FILTER='node-' npm run test:ci",
"test:deno": "FILTER='deno-' npm run test:ci",
"test:bun": "FILTER='bun-' npm run test:ci",
"update": "npx npu; npm run init",
"update": "npx npu;",
"prebuild": "rm -rf ./lib ./ci",
"build": "npx tsc; npx tsc -p tsconfig.test.json",
"postbuild": "npx tsx ./tools/compatibility/node.ts; npm audit",
Expand Down Expand Up @@ -63,7 +63,7 @@
],
"type": "commonjs",
"devDependencies": {
"@types/node": "^20.11.17",
"@types/node": "^20.11.19",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"eslint": "^8.56.0",
Expand Down
16 changes: 8 additions & 8 deletions src/bin/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#! /usr/bin/env node

import { escapeRegExp } from '../modules/get-files.js';
import { getArg } from '../helpers/get-arg.js';
import { getArg, hasArg } from '../helpers/get-arg.js';
import { poku } from '../index.js';

const rawDirs = getArg('include');
const rawFilter = getArg('filter');
const rawExclude = getArg('exclude');

const dirs = rawDirs?.split(',') || [];
const dirs = getArg('include')?.split(',') || [];
const filter = getArg('filter');
const parallel = hasArg('parallel');
const exclude = getArg('exclude');

poku(dirs, {
filter: rawFilter ? new RegExp(escapeRegExp(rawFilter)) : undefined,
exclude: rawExclude ? new RegExp(escapeRegExp(rawExclude)) : undefined,
filter: filter ? new RegExp(escapeRegExp(filter)) : undefined,
exclude: exclude ? new RegExp(escapeRegExp(exclude)) : undefined,
parallel,
});
3 changes: 3 additions & 0 deletions src/helpers/get-arg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ export const getArg = (arg: string): string | undefined => {

return undefined;
};

export const hasArg = (arg: string): boolean =>
args.some((a) => a.startsWith(`--${arg}`));
3 changes: 2 additions & 1 deletion src/modules/exit.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import process from 'node:process';
import { EOL } from 'node:os';
import { hr } from '../helpers/hr.js';
import { Code } from '../@types/code.js';

export const exit = (code: Code, quiet?: boolean) => {
!quiet &&
process.on('exit', (code) => {
console.log(`About to exit with code`, code);
console.log(`Exited with code`, code, EOL);
});

!quiet && hr();
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit f32d20a

Please sign in to comment.