impacted 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,6 +18,9 @@ jest $(git diff --name-only main | npx impacted)
18
18
 
19
19
  # Custom test pattern
20
20
  git diff --name-only main | npx impacted -p "src/**/*.spec.js"
21
+
22
+ # Multiple patterns
23
+ git diff --name-only main | npx impacted -p "test/**/*.test.js" -p "test/**/*.spec.js"
21
24
  ```
22
25
 
23
26
  ## GitHub Action
@@ -30,7 +33,7 @@ git diff --name-only main | npx impacted -p "src/**/*.spec.js"
30
33
  - uses: sozua/impacted@v1
31
34
  id: impacted
32
35
  with:
33
- pattern: '**/*.test.js'
36
+ pattern: '**/*.{test,spec}.{js,mjs,cjs,jsx}' # default
34
37
 
35
38
  - name: Run impacted tests
36
39
  if: steps.impacted.outputs.has-impacted == 'true'
package/bin/impacted.js CHANGED
@@ -4,12 +4,14 @@ import { findImpacted } from '../src/index.js';
4
4
 
5
5
  const args = process.argv.slice(2);
6
6
 
7
- // Parse -p/--pattern flag
8
- let pattern = '**/*.test.js';
9
- const patternIndex = args.findIndex((arg) => arg === '-p' || arg === '--pattern');
10
- if (patternIndex !== -1 && args[patternIndex + 1]) {
11
- pattern = args[patternIndex + 1];
7
+ // Parse -p/--pattern flags (supports multiple: -p "*.test.js" -p "*.spec.js")
8
+ const patterns = [];
9
+ for (let i = 0; i < args.length; i++) {
10
+ if ((args[i] === '-p' || args[i] === '--pattern') && args[i + 1]) {
11
+ patterns.push(args[++i]);
12
+ }
12
13
  }
14
+ const pattern = patterns.length > 0 ? patterns : '**/*.{test,spec}.{js,mjs,cjs,jsx}';
13
15
 
14
16
  // Read changed files from stdin
15
17
  let input = '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impacted",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Find test files impacted by code changes using static dependency analysis",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",