@@ -3,12 +3,22 @@ import { globSync } from 'glob';
33import { chmodSync , existsSync , readFileSync } from 'fs' ;
44import path from 'path' ;
55
6+ const branchName = process . argv [ 2 ] ;
7+ const commitSha = process . argv [ 3 ] ;
8+
9+ if ( typeof branchName !== 'string' ) {
10+ console . log ( 'Branch name missing! Exiting' ) ;
11+ process . exit ( - 1 ) ;
12+ }
13+ if ( typeof commitSha !== 'string' ) {
14+ console . log ( 'Commit sha missing! Exiting' ) ;
15+ process . exit ( - 1 ) ;
16+ }
17+
618const ROOT_DIR = process . cwd ( ) ;
719const readPkg = ( dir ) => JSON . parse ( readFileSync ( path . join ( dir , 'package.json' ) , 'utf8' ) ) ;
8- const execCmd = ( cmd , opts = { } ) => execSync ( cmd , { cwd : ROOT_DIR , encoding : 'utf-8' , stdio : 'inherit' , ...opts } )
20+ const execCmd = ( cmd , opts = { } ) => execSync ( cmd , { cwd : process . cwd ( ) , encoding : 'utf-8' , stdio : 'inherit' , ...opts } ) ;
921
10- const commitSha = execCmd ( 'git rev-parse HEAD' , { stdio : 'pipe' } ) . replace ( '\n' , '' ) ;
11- const branchName = execCmd ( 'git rev-parse --abbrev-ref HEAD' , { stdio : 'pipe' } ) . replace ( '\n' , '' ) ;
1222const pkgInfo = readPkg ( ROOT_DIR ) ;
1323const pkgFiles = pkgInfo . workspaces . map ( ( exp ) => globSync ( path . join ( exp , 'package.json' ) ) ) ;
1424const codecovPath = path . resolve ( ROOT_DIR , 'codecov' ) ;
0 commit comments