Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change stderr to stdout #70

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wet-parents-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@swc/cli": patch
---

fix: change stderr to stdout
8 changes: 4 additions & 4 deletions packages/cli/src/swc/dir.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { existsSync, promises } from "fs";
import { dirname, resolve } from "path";
import Piscina from "piscina";
import { stderr } from "process";
import { stdout } from "process";
import { format } from "util";
import { CompileStatus } from "./constants";
import { Callbacks, CliOptions } from "./options";
Expand Down Expand Up @@ -217,7 +217,7 @@ async function initialCompilation(
callbacks.onSuccess({ duration, compiled, copied });
}
} else if (!quiet) {
stderr.write(message);
stdout.write(message);
}
}

Expand Down Expand Up @@ -318,7 +318,7 @@ async function watchCompilation(
filename,
});
} else if (!quiet) {
stderr.write(
stdout.write(
format(
`Successfully compiled ${filename} with swc (%dms)\n`,
duration.toFixed(2)
Expand Down Expand Up @@ -357,7 +357,7 @@ async function watchCompilation(
filename,
});
} else if (!quiet) {
stderr.write(
stdout.write(
format(
`Successfully copied ${filename} with swc (%dms)\n`,
duration.toFixed(2)
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/swc/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as swc from "@swc/core";
import slash from "slash";
import { mkdirSync, writeFileSync, promises } from "fs";
import { dirname, join, relative } from "path";
import { stderr } from "process";
import { stdout } from "process";

export async function exists(path: string): Promise<boolean> {
let pathExists = true;
Expand Down Expand Up @@ -114,7 +114,7 @@ export function assertCompilationResult<T>(
}
if (!quiet && compiled + copied > 0) {
const copyResult = copied === 0 ? " " : ` (copied ${copied}) `;
stderr.write(
stdout.write(
`Successfully compiled ${compiled} ${
compiled !== 1 ? "files" : "file"
}${copyResult}with swc.\n`
Expand Down
Loading