Skip to content

Commit e0e1fde

Browse files
authored
🐛 fix: Add tty check on stdout.clearLine (#158)
1 parent 09ce889 commit e0e1fde

File tree

1 file changed

+8
-4
lines changed
  • packages/lobe-i18n/src/commands/TranslateLocale

1 file changed

+8
-4
lines changed

packages/lobe-i18n/src/commands/TranslateLocale/index.tsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ class TranslateLocale {
9797

9898
for (const locale of config.outputLocales) {
9999
for (const [index, filename] of files.entries()) {
100-
process.stdout.clearLine(0);
101-
process.stdout.cursorTo(0);
100+
if (process.stdout.isTTY) {
101+
process.stdout.clearLine(0);
102+
process.stdout.cursorTo(0);
103+
}
102104

103105
process.stdout.write(
104106
`${chalk.cyan(locale)}${chalk.gray(`[${index + 1}/${files.length}] - `)}${chalk.yellow(filename)}`,
@@ -118,8 +120,10 @@ class TranslateLocale {
118120
}
119121
}
120122

121-
process.stdout.clearLine(0);
122-
process.stdout.cursorTo(0);
123+
if (process.stdout.isTTY) {
124+
process.stdout.clearLine(0);
125+
process.stdout.cursorTo(0);
126+
}
123127
}
124128

125129
genFlatQuery() {

0 commit comments

Comments
 (0)