@jiyr0119/dsh-service-console 0.5.0 → 0.7.0

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.
package/dsh.plugin.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "id": "dsh-external/dsh-service-console",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "main": "./lib/index.js",
5
5
  "description": "本地开发服务控制台:发现监听端口,识别服务归属,安全查看/停止/重启。Local development service console for DSH.",
6
6
  "engines": {
7
- "dsh": ">=0.1.5-rc.2"
7
+ "dsh": ">=0.2.0-rc.2"
8
8
  },
9
9
  "contributes": {
10
10
  "tools": [],
package/dynamic/host.js CHANGED
@@ -37,13 +37,17 @@ return {
37
37
 
38
38
  async function runCommand(command, timeoutMs) {
39
39
  try {
40
- const spec = shell.resolve({ command, timeout: timeoutMs || 5000 })
41
- const res = await shell.run(spec)
42
- const stdout = typeof res.stdout === 'string' ? res.stdout
43
- : typeof res.output === 'string' ? res.output
44
- : typeof res.text === 'string' ? res.text : ''
45
- const stderr = typeof res.stderr === 'string' ? res.stderr : ''
46
- const code = res.code !== undefined ? res.code : res.exitCode !== undefined ? res.exitCode : null
40
+ // DSH 0.2.0:ShellExecutor.run()/start() 已移除,统一走 execute() + result();
41
+ // 结果的 stdout/stderr 是 CollectedOutput({ text, truncated })而非字符串。
42
+ const spec = shell.resolve({ command, timeoutMs: timeoutMs || 5000 })
43
+ const execution = await shell.execute(spec)
44
+ const res = await execution.result()
45
+ const pick = (v) => typeof v === 'string' ? v
46
+ : v && typeof v.text === 'string' ? v.text : ''
47
+ const stdout = pick(res.stdout)
48
+ const stderr = pick(res.stderr)
49
+ const code = res.exitCode !== undefined && res.exitCode !== null ? res.exitCode
50
+ : res.code !== undefined ? res.code : null
47
51
  return { stdout, stderr, code }
48
52
  } catch (e) { return { stdout: '', stderr: String((e && e.message) || e), code: null } }
49
53
  }