diff --git a/.github/assets/readme/screen-recording-2024-02-17-at-23.38.06.gif b/.github/assets/readme/screen-recording-2024-02-17-at-23.38.06.gif new file mode 100644 index 00000000..e0d331f4 Binary files /dev/null and b/.github/assets/readme/screen-recording-2024-02-17-at-23.38.06.gif differ diff --git a/README.md b/README.md index 12cc1f60..1c61c898 100644 --- a/README.md +++ b/README.md @@ -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' +``` + + + +--- + ## Install ### **Node.js** @@ -247,6 +255,8 @@ FILTER='unit' npx poku --include='...' Determines the mode of test execution across **sequential** or **parallel** modes. +- **in-code** + ```ts /** * @default @@ -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**: diff --git a/package-lock.json b/package-lock.json index 3579803a..708300ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "poku": "lib/bin/index.js" }, "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", @@ -26,6 +26,8 @@ "typescript": "^5.3.3" }, "engines": { + "bun": ">=0.5.3", + "deno": ">=1.17.0", "node": ">=6.0.0" } }, @@ -231,9 +233,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.11.17", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.17.tgz", - "integrity": "sha512-QmgQZGWu1Yw9TDyAP9ZzpFJKynYNeOvwMJmaxABfieQoVoiVOS6MN1WSpqpRcbeA5+RW82kraAVxCCJg+780Qw==", + "version": "20.11.19", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.19.tgz", + "integrity": "sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ==", "dev": true, "dependencies": { "undici-types": "~5.26.4" diff --git a/package.json b/package.json index 500ac1bf..13da4584 100755 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/src/bin/index.ts b/src/bin/index.ts index c63de402..b1ddf868 100644 --- a/src/bin/index.ts +++ b/src/bin/index.ts @@ -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, }); diff --git a/src/helpers/get-arg.ts b/src/helpers/get-arg.ts index 373ecec4..6b19f94b 100644 --- a/src/helpers/get-arg.ts +++ b/src/helpers/get-arg.ts @@ -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}`)); diff --git a/src/modules/exit.ts b/src/modules/exit.ts index c4407bcd..d297f1ef 100644 --- a/src/modules/exit.ts +++ b/src/modules/exit.ts @@ -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(); diff --git a/test/unit/runTestFile.test.ts b/test/unit/run-test-file.test.ts similarity index 100% rename from test/unit/runTestFile.test.ts rename to test/unit/run-test-file.test.ts diff --git a/test/unit/runTests.test.ts b/test/unit/run-tests.test.ts similarity index 100% rename from test/unit/runTests.test.ts rename to test/unit/run-tests.test.ts