mirror of
https://github.com/larksuite/cli.git
synced 2026-07-03 14:02:43 +08:00
* fix(selfupdate): use LookPath instead of Executable for binary verification (fixes #836) VerifyBinary was using vfs.Executable() to find the binary to run --version against. On Linux with global npm install, this returns the inode of the running binary (old version), not the newly installed one that sits behind npm's bin symlink. Switch to exec.LookPath("lark-cli") which resolves the PATH entry and follows npm's bin symlink to the correct newly installed version, matching what the user actually runs. * test(selfupdate): add LookPath-based tests for VerifyBinary Add TestVerifyBinaryLookPath, TestVerifyBinaryLookPathNotFound, and TestVerifyBinaryEmptyOutput. Expose execLookPath variable so tests can inject a mock LookPath and cover the full VerifyBinary execution path including version parsing and error branches. * test(selfupdate): add os/exec import and isolate config dir in VerifyBinary tests CodeRabbit feedback: - Add missing os/exec import for execLookPath variable - Add t.Setenv(LARKSUITE_CLI_CONFIG_DIR, ...) to each new test for config isolation * test(selfupdate): extract execLookPath to separate lookpath.go Move the execLookPath variable declaration to its own file so it is accessible to updater.go without the test-only import cycle. * fix(selfupdate): remove unused os/exec import from test file * fix(selfupdate): gofmt + fold lookpath hook and restore version fences - Move execLookPath into updater.go (drops redundant lookpath.go) - Document package-level mock: no t.Parallel() - Extend TestVerifyBinaryLookPath with exact-match regressions (0.0, 12.1.0 vs 2.1.0) Co-authored-by: CatfishGG <catfishgg@users.noreply.github.com>