mirror of
https://github.com/langgenius/dify.git
synced 2026-10-04 13:47:55 +08:00
style: format with vp fmt (#38803)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
fde08d24fe
commit
a84c2d36a3
6213 files changed
+227959
-187183
No files matched your search
+17
-28
@@ -14,10 +14,8 @@ export async function run(tree: CommandTree, argv: string[]): Promise<void> {
|
||||
const helpArgv: string[] = []
|
||||
|
||||
for (const a of argv) {
|
||||
if (a === 'help' || a === '--help' || a === '-h')
|
||||
continue
|
||||
if (a.startsWith('-'))
|
||||
break
|
||||
if (a === 'help' || a === '--help' || a === '-h') continue
|
||||
if (a.startsWith('-')) break
|
||||
helpArgv.push(a)
|
||||
}
|
||||
|
||||
@@ -48,7 +46,7 @@ export async function run(tree: CommandTree, argv: string[]): Promise<void> {
|
||||
// misses them; surface their subtree instead of erroring. A strict-prefix
|
||||
// match over the full-depth command walk keeps this purely derived.
|
||||
const subtree = collectCommands(tree).filter(
|
||||
c => c.path.length > helpArgv.length && helpArgv.every((token, i) => c.path[i] === token),
|
||||
(c) => c.path.length > helpArgv.length && helpArgv.every((token, i) => c.path[i] === token),
|
||||
)
|
||||
|
||||
if (subtree.length > 0) {
|
||||
@@ -63,8 +61,7 @@ export async function run(tree: CommandTree, argv: string[]): Promise<void> {
|
||||
if (suggestions.length > 0) {
|
||||
process.stderr.write('\nDid you mean:\n')
|
||||
|
||||
for (const s of suggestions.slice(0, 5))
|
||||
process.stderr.write(` ${s}\n`)
|
||||
for (const s of suggestions.slice(0, 5)) process.stderr.write(` ${s}\n`)
|
||||
}
|
||||
|
||||
process.exit(1)
|
||||
@@ -84,8 +81,7 @@ export async function run(tree: CommandTree, argv: string[]): Promise<void> {
|
||||
if (suggestions.length > 0) {
|
||||
process.stderr.write('\nDid you mean:\n')
|
||||
|
||||
for (const s of suggestions.slice(0, 5))
|
||||
process.stderr.write(` ${s}\n`)
|
||||
for (const s of suggestions.slice(0, 5)) process.stderr.write(` ${s}\n`)
|
||||
}
|
||||
|
||||
process.exit(1)
|
||||
@@ -100,15 +96,13 @@ export async function run(tree: CommandTree, argv: string[]): Promise<void> {
|
||||
cmd.processGlobalFlags(commandArgv)
|
||||
|
||||
const output = await cmd.run(commandArgv)
|
||||
if (output !== undefined)
|
||||
process.stdout.write(stringifyOutput(output))
|
||||
}
|
||||
catch (err) {
|
||||
if ((err as NodeJS.ErrnoException).code === 'EPIPE')
|
||||
process.exit(0)
|
||||
const e = err instanceof BaseError
|
||||
? err
|
||||
: unknownError(err instanceof Error ? err.message : String(err), err)
|
||||
if (output !== undefined) process.stdout.write(stringifyOutput(output))
|
||||
} catch (err) {
|
||||
if ((err as NodeJS.ErrnoException).code === 'EPIPE') process.exit(0)
|
||||
const e =
|
||||
err instanceof BaseError
|
||||
? err
|
||||
: unknownError(err instanceof Error ? err.message : String(err), err)
|
||||
const format = sniffOutputFormat(argv)
|
||||
process.stderr.write(`${formatErrorForCli(e, { format, isErrTTY: process.stderr.isTTY })}\n`)
|
||||
process.exit(e.exit())
|
||||
@@ -118,21 +112,16 @@ export async function run(tree: CommandTree, argv: string[]): Promise<void> {
|
||||
export function sniffOutputFormat(argv: readonly string[]): string {
|
||||
for (let i = 0; i < argv.length; i++) {
|
||||
const t = argv[i]
|
||||
if (t === undefined)
|
||||
continue
|
||||
if (t === '--')
|
||||
return ''
|
||||
if (t === undefined) continue
|
||||
if (t === '--') return ''
|
||||
|
||||
if (t === '--output' || t === '-o') {
|
||||
const next = argv[i + 1]
|
||||
if (next !== undefined && !next.startsWith('-'))
|
||||
return next
|
||||
if (next !== undefined && !next.startsWith('-')) return next
|
||||
continue
|
||||
}
|
||||
if (t.startsWith('--output='))
|
||||
return t.slice('--output='.length)
|
||||
if (t.startsWith('-o='))
|
||||
return t.slice('-o='.length)
|
||||
if (t.startsWith('--output=')) return t.slice('--output='.length)
|
||||
if (t.startsWith('-o=')) return t.slice('-o='.length)
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user