@atomservice/core 0.1.12 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/core.hooks.ts +10 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomservice/core",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "atomservice 编排核心:defineService、依赖拓扑、生命周期与 CLI 运行时",
5
5
  "type": "module",
6
6
  "author": "openorson",
package/src/core.hooks.ts CHANGED
@@ -59,8 +59,8 @@ export function useShell(): typeof Bun.$ {
59
59
  // 默认抛错(沿用 Bun.$ 行为),服务通过 .nothrow() 显式忽略;.quiet() 抑制实时输出
60
60
  if (!process.env.ATOMSERVICE_VERBOSE) return Reflect.apply(shell, undefined, args).quiet()
61
61
 
62
- // verbose 模式:内部以 nothrow 捕获结果用于打印,再按需重新抛错
63
- const cmd = Reflect.apply(shell, undefined, args).quiet().nothrow()
62
+ // verbose 模式:不加 .quiet(),让输出实时流式打印到终端
63
+ const cmd = Reflect.apply(shell, undefined, args).nothrow()
64
64
  const strings = args[0] as TemplateStringsArray
65
65
  const values = args.slice(1)
66
66
  const cmdStr = strings.reduce(
@@ -71,7 +71,6 @@ export function useShell(): typeof Bun.$ {
71
71
  "",
72
72
  )
73
73
 
74
- // 惰性执行:仅在首次 await 时运行一次,throwOnError 由是否调用过 .nothrow() 决定
75
74
  let throwOnError = true
76
75
  let started: Promise<Bun.$.ShellOutput> | undefined
77
76
  const exec = () => {
@@ -79,17 +78,16 @@ export function useShell(): typeof Bun.$ {
79
78
  started = (async () => {
80
79
  process.stdout.write(`${BAR}│${RESET} ${CMD}$ ${short(cmdStr)}${RESET}\n`)
81
80
  const result = await cmd
82
- const printLines = (buf: Buffer | undefined) => {
83
- for (const line of (buf?.toString() ?? "").split("\n")) {
84
- const trimmed = line.trim()
85
- if (!trimmed) continue
86
- // 过滤 podman-compose 透传的 provider 提示噪音
87
- if (trimmed.includes("Executing external compose provider")) continue
88
- process.stdout.write(`${BAR}│${RESET} ${OUT}${short(line.trimEnd())}${RESET}\n`)
81
+ if (result.exitCode !== 0) {
82
+ const stderr = result.stderr?.toString().trim()
83
+ if (stderr) {
84
+ for (const line of stderr.split("\n")) {
85
+ const trimmed = line.trim()
86
+ if (!trimmed) continue
87
+ process.stdout.write(`${BAR}│${RESET} ${OUT}${short(line.trimEnd())}${RESET}\n`)
88
+ }
89
89
  }
90
90
  }
91
- printLines(result.stdout)
92
- printLines(result.stderr)
93
91
  if (throwOnError && result.exitCode !== 0) {
94
92
  throw new Error(result.stderr?.toString().trim() || `Exit code ${result.exitCode}`)
95
93
  }