File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616 "prepare" : " husky install" ,
1717 "commit" : " git-cz" ,
1818 "knip" : " knip" ,
19- "ci:nx" : " cross-env-shell NODE_OPTIONS= \" --import tsx\" \" TSX_TSCONFIG_PATH=${GITHUB_WORKSPACE:-$PWD}/tsconfig.base.json \" nx" ,
20- "ci:node" : " cross-env-shell NODE_OPTIONS= \" --import tsx\" \" TSX_TSCONFIG_PATH=${GITHUB_WORKSPACE:-$PWD}/tsconfig.base.json \" node"
19+ "ci:nx" : " node tools/scripts/ci- tsx.js nx" ,
20+ "ci:node" : " node tools/scripts/ci- tsx.js node"
2121 },
2222 "private" : true ,
2323 "dependencies" : {
Original file line number Diff line number Diff line change 1+ // @ts -check
2+ import { spawn } from 'node:child_process' ;
3+ import { resolve } from 'node:path' ;
4+
5+ // Determine the workspace root (GITHUB_WORKSPACE or current working directory)
6+ const workspaceRoot = process . env . GITHUB_WORKSPACE || process . cwd ( ) ;
7+ const tsconfigPath = resolve ( workspaceRoot , 'tsconfig.base.json' ) ;
8+
9+ // Set up environment variables
10+ const env = {
11+ ...process . env ,
12+ NODE_OPTIONS : '--import tsx' ,
13+ TSX_TSCONFIG_PATH : tsconfigPath ,
14+ } ;
15+
16+ // Get the command and its arguments from the command line
17+ const [ command , ...args ] = process . argv . slice ( 2 ) ;
18+
19+ if ( ! command ) {
20+ console . error ( 'Usage: node ci-tsx.js <command> [args...]' ) ;
21+ console . error ( 'Example: node ci-tsx.js nx affected -t test' ) ;
22+ process . exit ( 1 ) ;
23+ }
24+
25+ // Spawn the command with the configured environment
26+ const child = spawn ( command , args , {
27+ env,
28+ stdio : 'inherit' ,
29+ shell : true ,
30+ } ) ;
31+
32+ // Forward exit code
33+ child . on ( 'exit' , ( code , signal ) => {
34+ if ( signal ) {
35+ process . kill ( process . pid , signal ) ;
36+ } else {
37+ process . exit ( code ?? 0 ) ;
38+ }
39+ } ) ;
40+
41+ // Handle errors
42+ child . on ( 'error' , error => {
43+ console . error ( 'Failed to start child process:' , error ) ;
44+ process . exit ( 1 ) ;
45+ } ) ;
You can’t perform that action at this time.
0 commit comments