forked from wangziqi/gongxue-base
fix: keep SMS smoke JSON output clean
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { createInterface } from 'node:readline/promises';
|
||||
import { stdin as input, stdout as output } from 'node:process';
|
||||
import { stdin as input, stdout as output, stderr } from 'node:process';
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||
|
||||
const DEFAULT_TIMEOUT_MS = 15_000;
|
||||
@@ -108,7 +108,7 @@ function assertOk(name, response) {
|
||||
|
||||
async function promptCode(config) {
|
||||
if (config.code) return config.code;
|
||||
const readline = createInterface({ input, output });
|
||||
const readline = createInterface({ input, output: config.jsonOutput ? stderr : output });
|
||||
try {
|
||||
return (await readline.question('Enter received SMS verification code: ')).trim();
|
||||
} finally {
|
||||
@@ -118,7 +118,7 @@ async function promptCode(config) {
|
||||
|
||||
async function promptBindCode(config) {
|
||||
if (config.bindCode) return config.bindCode;
|
||||
const readline = createInterface({ input, output });
|
||||
const readline = createInterface({ input, output: config.jsonOutput ? stderr : output });
|
||||
try {
|
||||
return (await readline.question('Enter received bind_phone SMS verification code: ')).trim();
|
||||
} finally {
|
||||
@@ -216,7 +216,7 @@ async function runRemoteSmsLoginSmoke(inputConfig, options = {}) {
|
||||
async function main() {
|
||||
const options = parseArgs(process.argv.slice(2));
|
||||
try {
|
||||
const result = await runRemoteSmsLoginSmoke(null, { quiet: options.quiet || options.json });
|
||||
const result = await runRemoteSmsLoginSmoke({ ...buildConfig(), jsonOutput: options.json }, { quiet: options.quiet || options.json });
|
||||
if (options.json) console.log(JSON.stringify(result.summary, null, 2));
|
||||
} catch (error) {
|
||||
if (options.json) {
|
||||
|
||||
Reference in New Issue
Block a user