Skip to content

Commit 4a57e6c

Browse files
committed
Use consola
1 parent 93aecc2 commit 4a57e6c

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/commands/build.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,17 @@ function compilerOptionsToArgs(options: Record<string, unknown>): string[] {
5858
return Object.entries(options).flatMap(([key, value]) => [`--${key}`, `${value}`]);
5959
}
6060

61-
function assertTypeScriptBuildResult(result: Awaited<ReturnType<typeof execa>>) {
61+
function assertTypeScriptBuildResult(result: Awaited<ReturnType<typeof execa>>, reporter: ConsolaInstance) {
6262
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);
6564
throw new Error('TypeScript compiler exited with non-zero exit code.');
6665
}
6766
}
6867

6968
async function buildTypeScript(
7069
buildPath: string,
7170
options: { cwd: string; tsconfig?: string; incremental?: boolean },
71+
reporter: ConsolaInstance,
7272
) {
7373
let tsconfig = options.tsconfig;
7474
if (!tsconfig && (await fse.exists(join(options.cwd, DEFAULT_TS_BUILD_CONFIG)))) {
@@ -83,6 +83,7 @@ async function buildTypeScript(
8383
'--outDir',
8484
join(buildPath, 'esm'),
8585
]),
86+
reporter,
8687
);
8788

8889
assertTypeScriptBuildResult(
@@ -94,6 +95,7 @@ async function buildTypeScript(
9495
'--outDir',
9596
join(buildPath, 'cjs'),
9697
]),
98+
reporter,
9799
);
98100
}
99101

@@ -133,7 +135,7 @@ export const buildCommand = createCommand<
133135
if (!incremental) {
134136
await fse.remove(buildPath);
135137
}
136-
await buildTypeScript(buildPath, { cwd, tsconfig, incremental });
138+
await buildTypeScript(buildPath, { cwd, tsconfig, incremental }, reporter);
137139
const pkg = await fse.readJSON(resolve(cwd, 'package.json'));
138140
const fullName: string = pkg.name;
139141

@@ -170,7 +172,7 @@ export const buildCommand = createCommand<
170172
if (!incremental) {
171173
await fse.remove(bobBuildPath);
172174
}
173-
await buildTypeScript(bobBuildPath, { cwd, tsconfig, incremental });
175+
await buildTypeScript(bobBuildPath, { cwd, tsconfig, incremental }, reporter);
174176

175177
await Promise.all(
176178
packageInfoList.map(({ cwd, pkg, fullName }) =>
@@ -331,9 +333,9 @@ async function build({
331333

332334
if (pkg.bin) {
333335
if (globalThis.process.platform === 'win32') {
334-
console.warn(
336+
reporter.warn(
335337
'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.',
337339
);
338340
} else {
339341
await Promise.all(
@@ -423,7 +425,7 @@ export function validatePackageJson(
423425
received,
424426
expected,
425427
`${pkg.name}: "${key}" equals "${JSON.stringify(received)}"` +
426-
`, should be "${JSON.stringify(expected)}".`,
428+
`, should be "${JSON.stringify(expected)}".`,
427429
);
428430
}
429431

0 commit comments

Comments
 (0)