@@ -4,30 +4,32 @@ const { findNextJsProjectRoot } = require('../src/_internal');
44const { execSync } = require ( 'child_process' ) ;
55const { join } = require ( 'path' ) ;
66
7- if ( process . argv . includes ( '--compile' ) ) {
8- try {
9- const packageRoot = findNextJsProjectRoot ( __dirname ) ;
10- if ( ! packageRoot ) {
11- throw new Error ( 'Could not find Next.js project root' ) ;
12- }
7+ ( async ( ) => {
8+ if ( process . argv . includes ( '--compile' ) ) {
9+ try {
10+ const packageRoot = await findNextJsProjectRoot ( __dirname ) ;
11+ if ( ! packageRoot ) {
12+ throw new Error ( 'Could not find Next.js project root' ) ;
13+ }
1314
14- console . log ( 'Running TypeScript compiler...' ) ;
15- execSync ( 'npx tsc --noEmit compiler/src/index.ts' , {
16- stdio : 'inherit' ,
17- cwd : join ( packageRoot , 'node_modules/typedcssx' ) ,
18- } ) ;
15+ console . log ( 'Running TypeScript compiler...' ) ;
16+ execSync ( 'npx tsc --noEmit compiler/src/index.ts' , {
17+ stdio : 'inherit' ,
18+ cwd : join ( packageRoot , 'node_modules/typedcssx' ) ,
19+ } ) ;
1920
20- console . log ( 'Executing compiler...' ) ;
21- execSync ( 'npx tsx compiler/src/index.ts' , {
22- stdio : 'inherit' ,
23- cwd : join ( packageRoot , 'node_modules/typedcssx' ) ,
24- } ) ;
21+ console . log ( 'Executing compiler...' ) ;
22+ execSync ( 'npx tsx compiler/src/index.ts' , {
23+ stdio : 'inherit' ,
24+ cwd : join ( packageRoot , 'node_modules/typedcssx' ) ,
25+ } ) ;
2526
26- console . log ( 'Compilation completed successfully.' ) ;
27- } catch ( error ) {
28- console . error ( 'Compilation failed:' , error . message ) ;
29- process . exit ( 1 ) ;
27+ console . log ( 'Compilation completed successfully.' ) ;
28+ } catch ( error ) {
29+ console . error ( 'Compilation failed:' , error . message ) ;
30+ process . exit ( 1 ) ;
31+ }
32+ } else {
33+ console . log ( 'Usage: typedcssx --compile' ) ;
3034 }
31- } else {
32- console . log ( 'Usage: typedcssx --compile' ) ;
33- }
35+ } ) ( ) ;
0 commit comments