zlh-agent/internal/provision/devcontainer/node/verify.go
2025-12-21 22:11:44 +00:00

36 lines
709 B
Go

package node
import (
"fmt"
"os"
"os/exec"
"zlh-agent/internal/state"
)
const (
nodeBin = "/opt/zlh/runtime/node/bin/node"
npmBin = "/opt/zlh/runtime/node/bin/npm"
)
func Verify(cfg state.Config) error {
// Node must exist
if _, err := os.Stat(nodeBin); err != nil {
return fmt.Errorf("node binary missing at %s", nodeBin)
}
// Node must execute
if err := exec.Command(nodeBin, "-v").Run(); err != nil {
return fmt.Errorf("node runtime not executable: %w", err)
}
// npm must exist (installation completeness)
if _, err := os.Stat(npmBin); err != nil {
return fmt.Errorf("npm missing at %s", npmBin)
}
// Do NOT execute npm here — it is PATH-dependent by design
return nil
}