@@ -58,17 +58,17 @@ function compilerOptionsToArgs(options: Record<string, unknown>): string[] {
58
58
return Object . entries ( options ) . flatMap ( ( [ key , value ] ) => [ `--${ key } ` , `${ value } ` ] ) ;
59
59
}
60
60
61
- function assertTypeScriptBuildResult ( result : Awaited < ReturnType < typeof execa > > ) {
61
+ function assertTypeScriptBuildResult ( result : Awaited < ReturnType < typeof execa > > , reporter : ConsolaInstance ) {
62
62
if ( result . exitCode !== 0 ) {
63
- console . log ( 'TypeScript compiler exited with non-zero exit code.' ) ;
64
- console . log ( result . stdout ) ;
63
+ reporter . error ( result . stdout ) ;
65
64
throw new Error ( 'TypeScript compiler exited with non-zero exit code.' ) ;
66
65
}
67
66
}
68
67
69
68
async function buildTypeScript (
70
69
buildPath : string ,
71
70
options : { cwd : string ; tsconfig ?: string ; incremental ?: boolean } ,
71
+ reporter : ConsolaInstance ,
72
72
) {
73
73
let tsconfig = options . tsconfig ;
74
74
if ( ! tsconfig && ( await fse . exists ( join ( options . cwd , DEFAULT_TS_BUILD_CONFIG ) ) ) ) {
@@ -83,6 +83,7 @@ async function buildTypeScript(
83
83
'--outDir' ,
84
84
join ( buildPath , 'esm' ) ,
85
85
] ) ,
86
+ reporter ,
86
87
) ;
87
88
88
89
assertTypeScriptBuildResult (
@@ -94,6 +95,7 @@ async function buildTypeScript(
94
95
'--outDir' ,
95
96
join ( buildPath , 'cjs' ) ,
96
97
] ) ,
98
+ reporter ,
97
99
) ;
98
100
}
99
101
@@ -133,7 +135,7 @@ export const buildCommand = createCommand<
133
135
if ( ! incremental ) {
134
136
await fse . remove ( buildPath ) ;
135
137
}
136
- await buildTypeScript ( buildPath , { cwd, tsconfig, incremental } ) ;
138
+ await buildTypeScript ( buildPath , { cwd, tsconfig, incremental } , reporter ) ;
137
139
const pkg = await fse . readJSON ( resolve ( cwd , 'package.json' ) ) ;
138
140
const fullName : string = pkg . name ;
139
141
@@ -170,7 +172,7 @@ export const buildCommand = createCommand<
170
172
if ( ! incremental ) {
171
173
await fse . remove ( bobBuildPath ) ;
172
174
}
173
- await buildTypeScript ( bobBuildPath , { cwd, tsconfig, incremental } ) ;
175
+ await buildTypeScript ( bobBuildPath , { cwd, tsconfig, incremental } , reporter ) ;
174
176
175
177
await Promise . all (
176
178
packageInfoList . map ( ( { cwd, pkg, fullName } ) =>
@@ -331,9 +333,9 @@ async function build({
331
333
332
334
if ( pkg . bin ) {
333
335
if ( globalThis . process . platform === 'win32' ) {
334
- console . warn (
336
+ reporter . warn (
335
337
'Package includes bin files, but cannot set the executable bit on Windows.\n' +
336
- 'Please manually set the executable bit on the bin files before publishing.' ,
338
+ 'Please manually set the executable bit on the bin files before publishing.' ,
337
339
) ;
338
340
} else {
339
341
await Promise . all (
@@ -423,7 +425,7 @@ export function validatePackageJson(
423
425
received ,
424
426
expected ,
425
427
`${ pkg . name } : "${ key } " equals "${ JSON . stringify ( received ) } "` +
426
- `, should be "${ JSON . stringify ( expected ) } ".` ,
428
+ `, should be "${ JSON . stringify ( expected ) } ".` ,
427
429
) ;
428
430
}
429
431
0 commit comments