From 85bb755cad89cab36634d921fbe0678e250baee7 Mon Sep 17 00:00:00 2001 From: AI Engineer Date: Sun, 21 Jun 2026 10:12:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(shell):=20=E5=85=B7=E5=90=8D=E5=8C=96=20JS?= =?UTF-8?q?=20=E5=AF=BC=E5=87=BA=E5=B9=B6=E5=8A=A8=E6=80=81=E5=8C=85?= =?UTF-8?q?=E8=A3=B9=E9=94=99=E8=AF=AF=EF=BC=88by=20AI=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 5 +++++ go.mod | 4 ++-- js_export.go | 20 ++++++++++++++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 914e0d5..3245caa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG - shell +## v1.5.3 (2026-06-21) +- **重构与错误堆栈支持**: + - 重构 `js_export.go`,将 `Run` 和 `RunCommand` 注册为具名函数,并动态使用 `jsmod.MakeError` 包裹错误。 + - 升级 `jsmod` 依赖至 v1.5.3,`cast` 依赖至 v1.5.3。 + ## v1.5.2 (2026-06-11) - **版本对齐**: 基础设施全局对齐 v1.5.2。 diff --git a/go.mod b/go.mod index 6eea731..3f1c6aa 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,6 @@ module apigo.cc/go/shell go 1.25.0 -require apigo.cc/go/cast v1.5.2 +require apigo.cc/go/cast v1.5.3 -require apigo.cc/go/jsmod v1.5.2 +require apigo.cc/go/jsmod v1.5.3 diff --git a/js_export.go b/js_export.go index cc8be4d..74741fc 100644 --- a/js_export.go +++ b/js_export.go @@ -4,7 +4,23 @@ import "apigo.cc/go/jsmod" func init() { jsmod.Register("shell", map[string]any{ - "Run": Run, - "RunCommand": RunCommand, + "Run": jsRun, + "RunCommand": jsRunCommand, }, "Run", "RunCommand") } + +func jsRun(name string, args []string, opts *Options) (*CommandResult, error) { + res, err := Run(name, args, opts) + if err != nil { + return nil, jsmod.MakeError(err) + } + return res, nil +} + +func jsRunCommand(command string, opts *Options) (*CommandResult, error) { + res, err := RunCommand(command, opts) + if err != nil { + return nil, jsmod.MakeError(err) + } + return res, nil +}