1818 * --yarnBinary [path] - path to yarn binary, defaults to yarn
1919 */
2020
21- const { echo , exec , exit } = require ( 'shelljs ' ) ;
21+ const { execSync } = require ( 'child_process ' ) ;
2222const argv = require ( 'yargs' ) . argv ;
2323
2424const numberOfMaxWorkers = argv . maxWorkers || 1 ;
@@ -29,29 +29,29 @@ const FLOW_BINARY = argv.flowBinary;
2929const YARN_BINARY = argv . yarnBinary || 'yarn' ;
3030
3131function describe ( message ) {
32- echo ( `\n\n>>>>> ${ message } \n\n\n` ) ;
32+ console . log ( `\n\n>>>>> ${ message } \n\n\n` ) ;
3333}
3434
3535try {
36- echo ( 'Executing JavaScript tests' ) ;
36+ console . log ( 'Executing JavaScript tests' ) ;
3737
3838 describe ( 'Test: feature flags codegen' ) ;
39- if ( exec ( `${ YARN_BINARY } run featureflags --verify-unchanged` ) . code ) {
40- echo ( 'Failed to run featureflags check.' ) ;
39+ if ( execSync ( `${ YARN_BINARY } run featureflags --verify-unchanged` ) . code ) {
40+ console . log ( 'Failed to run featureflags check.' ) ;
4141 exitCode = 1 ;
4242 throw Error ( exitCode ) ;
4343 }
4444
4545 describe ( 'Test: eslint' ) ;
46- if ( exec ( `${ YARN_BINARY } run lint` ) . code ) {
47- echo ( 'Failed to run eslint.' ) ;
46+ if ( execSync ( `${ YARN_BINARY } run lint` ) . code ) {
47+ console . log ( 'Failed to run eslint.' ) ;
4848 exitCode = 1 ;
4949 throw Error ( exitCode ) ;
5050 }
5151
5252 describe ( 'Test: No JS build artifacts' ) ;
53- if ( exec ( `${ YARN_BINARY } run build --validate` ) . code ) {
54- echo ( 'Failed, there are build artifacts in this commit.' ) ;
53+ if ( execSync ( `${ YARN_BINARY } run build --validate` ) . code ) {
54+ console . log ( 'Failed, there are build artifacts in this commit.' ) ;
5555 exitCode = 1 ;
5656 throw Error ( exitCode ) ;
5757 }
6161 FLOW_BINARY == null
6262 ? `${ YARN_BINARY } run flow-check`
6363 : `${ FLOW_BINARY } check` ;
64- if ( exec ( flowCommand ) . code ) {
65- echo ( 'Failed to run flow.' ) ;
64+ if ( execSync ( flowCommand ) . code ) {
65+ console . log ( 'Failed to run flow.' ) ;
6666 exitCode = 1 ;
6767 throw Error ( exitCode ) ;
6868 }
@@ -77,47 +77,46 @@ try {
7777
7878 describe ( 'Test: Build @react-native/codegen' ) ;
7979 if (
80- exec ( `${ YARN_BINARY } --cwd ./packages/react-native-codegen run build` ) . code
80+ execSync ( `${ YARN_BINARY } --cwd ./packages/react-native-codegen run build` )
81+ . code
8182 ) {
82- echo ( 'Failed to build @react-native/codegen.' ) ;
83+ console . log ( 'Failed to build @react-native/codegen.' ) ;
8384 exitCode = 1 ;
8485 throw Error ( exitCode ) ;
8586 }
8687 describe ( 'Test: Build @react-native/codegen-typescript-test' ) ;
8788 if (
88- exec (
89+ execSync (
8990 `${ YARN_BINARY } --cwd ./private/react-native-codegen-typescript-test run build` ,
9091 ) . code
9192 ) {
92- echo ( 'Failed to build @react-native/codegen-typescript-test.' ) ;
93+ console . log ( 'Failed to build @react-native/codegen-typescript-test.' ) ;
9394 exitCode = 1 ;
9495 throw Error ( exitCode ) ;
9596 }
9697
97- // TODO: Improve handling of `exec` (e.g. check `signal`). Also, why use `shelljs`?
98-
9998 describe ( 'Test: Jest' ) ;
10099 if (
101- exec (
100+ execSync (
102101 `${ JEST_BINARY } --maxWorkers=${ numberOfMaxWorkers } --ci --reporters="default" --reporters="jest-junit"` ,
103102 ) . code
104103 ) {
105- echo ( 'Failed to run JavaScript tests.' ) ;
106- echo ( 'Most likely the code is broken.' ) ;
104+ console . log ( 'Failed to run JavaScript tests.' ) ;
105+ console . log ( 'Most likely the code is broken.' ) ;
107106 exitCode = 1 ;
108107 throw Error ( exitCode ) ;
109108 }
110109
111110 describe ( 'Test: TypeScript tests' ) ;
112- if ( exec ( `${ YARN_BINARY } run test-typescript` ) . code ) {
113- echo ( 'Failed to run TypeScript tests.' ) ;
111+ if ( execSync ( `${ YARN_BINARY } run test-typescript` ) . code ) {
112+ console . log ( 'Failed to run TypeScript tests.' ) ;
114113 exitCode = 1 ;
115114 throw Error ( exitCode ) ;
116115 }
117116
118117 exitCode = 0 ;
119118} finally {
120119 // Do cleanup here
121- echo ( 'Finished.' ) ;
120+ console . log ( 'Finished.' ) ;
122121}
123- exit ( exitCode ) ;
122+ process . exit ( exitCode ) ;
0 commit comments