File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88// Node 20 does not support --experimental-strip-types flag.
99
1010import { spawn , execSync } from 'node:child_process' ;
11+ import { glob , readFile } from 'node:fs/promises' ;
1112import path from 'node:path' ;
1213import process from 'node:process' ;
1314
@@ -38,10 +39,23 @@ if (userArgs.length > 0) {
3839 }
3940} else {
4041 const isNode20 = process . version . startsWith ( 'v20.' ) ;
41- if ( isNode20 ) {
42- files . push ( 'build/tests' ) ;
43- } else {
44- files . push ( 'build/tests/**/*.test.js' ) ;
42+ if ( flags . includes ( '--test-only' ) ) {
43+ for await ( const tsFile of glob ( 'tests/**/*.test.ts' ) ) {
44+ const content = await readFile ( tsFile , 'utf8' ) ;
45+ if ( content . includes ( '.only(' ) ) {
46+ files . push ( path . join ( 'build' , tsFile . replace ( / \. t s $ / , '.js' ) ) ) ;
47+ }
48+ }
49+ if ( files . length === 0 ) {
50+ console . warn ( 'no files contain .only' ) ;
51+ process . exit ( 0 ) ;
52+ }
53+ } else if ( files . length === 0 ) {
54+ if ( isNode20 ) {
55+ files . push ( 'build/tests' ) ;
56+ } else {
57+ files . push ( 'build/tests/**/*.test.js' ) ;
58+ }
4559 }
4660}
4761
You can’t perform that action at this time.
0 commit comments