@@ -7,15 +7,17 @@ import { existsSync } from 'node:fs'
77import path from 'node:path'
88import { fileURLToPath } from 'node:url'
99
10- import { printError , printHeader } from './utils/cli-helpers.mjs'
10+ import colors from 'yoctocolors-cjs'
11+
12+ import { printError , printHeader , replaceHeader } from './utils/cli-helpers.mjs'
1113
1214const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
1315const rootPath = path . join ( __dirname , '..' )
1416
1517/**
1618 * Run a command and return a promise that resolves when it completes.
1719 */
18- function runCommand ( command , args , label ) {
20+ function _runCommand ( command , args , label ) {
1921 return new Promise ( ( resolve , reject ) => {
2022 printHeader ( label )
2123 const child = spawn ( command , args , {
@@ -45,24 +47,55 @@ async function main() {
4547 // Step 1: Generate package exports (only if dist/ exists)
4648 const distPath = path . join ( rootPath , 'dist' )
4749 if ( existsSync ( distPath ) ) {
48- await runCommand (
50+ printHeader ( 'Package Exports' )
51+ const exportChild = spawn (
4952 'node' ,
5053 [ path . join ( __dirname , 'generate-package-exports.mjs' ) ] ,
51- 'Package Exports' ,
54+ {
55+ stdio : 'pipe' ,
56+ cwd : rootPath ,
57+ ...( process . platform === 'win32' && { shell : true } ) ,
58+ } ,
5259 )
60+ await new Promise ( ( resolve , reject ) => {
61+ exportChild . on ( 'exit' , code => {
62+ if ( code === 0 ) {
63+ replaceHeader ( colors . green ( '✓ Package exports generated' ) )
64+ resolve ( )
65+ } else {
66+ reject ( new Error ( `Package exports exited with code ${ code } ` ) )
67+ }
68+ } )
69+ exportChild . on ( 'error' , reject )
70+ } )
5371 } else {
5472 printHeader ( 'Skipping Package Exports (dist/ not found)' )
5573 }
5674
57- // Step 2: Fix default imports
58- await runCommand (
75+ // Step 2: Fix default imports (prints its own header and success)
76+ const child = spawn (
5977 'node' ,
6078 [ path . join ( __dirname , 'fix-default-imports.mjs' ) ] ,
61- 'Default Imports' ,
79+ {
80+ stdio : 'inherit' ,
81+ cwd : rootPath ,
82+ ...( process . platform === 'win32' && { shell : true } ) ,
83+ } ,
6284 )
85+ await new Promise ( ( resolve , reject ) => {
86+ child . on ( 'exit' , code => {
87+ if ( code === 0 ) {
88+ resolve ( )
89+ } else {
90+ reject ( new Error ( `Fix default imports exited with code ${ code } ` ) )
91+ }
92+ } )
93+ child . on ( 'error' , reject )
94+ } )
6395
6496 // Step 3: Run Biome auto-fix
65- await runCommand (
97+ printHeader ( 'Biome Auto-fix' )
98+ const biomeChild = spawn (
6699 'pnpm' ,
67100 [
68101 'exec' ,
@@ -73,8 +106,23 @@ async function main() {
73106 '.' ,
74107 ...process . argv . slice ( 2 ) ,
75108 ] ,
76- 'Biome Auto-fix' ,
109+ {
110+ stdio : 'inherit' ,
111+ cwd : rootPath ,
112+ ...( process . platform === 'win32' && { shell : true } ) ,
113+ } ,
77114 )
115+ await new Promise ( ( resolve , reject ) => {
116+ biomeChild . on ( 'exit' , code => {
117+ if ( code === 0 ) {
118+ replaceHeader ( colors . green ( '✓ Biome auto-fix complete' ) , 1 )
119+ resolve ( )
120+ } else {
121+ reject ( new Error ( `Biome auto-fix exited with code ${ code } ` ) )
122+ }
123+ } )
124+ biomeChild . on ( 'error' , reject )
125+ } )
78126
79127 process . exitCode = 0
80128 } catch ( error ) {
0 commit comments