mehh
This commit is contained in:
parent
a606043450
commit
00a56fa985
@ -195,6 +195,23 @@ func RemovePackage(name string) error {
|
||||
if _, err := os.Stat(packagePath); os.IsNotExist(err) {
|
||||
return errors.New("package not found")
|
||||
}
|
||||
manifestPath := filepath.Join(packagePath, "manifest.json")
|
||||
data, err := ioutil.ReadFile(manifestPath)
|
||||
if err == nil {
|
||||
var m manifest.Manifest
|
||||
if err := json.Unmarshal(data, &m); err == nil {
|
||||
if len(m.Uninstall) > 0 {
|
||||
for _, cmdStr := range m.Uninstall {
|
||||
cmd := exec.Command("sh", "-c", cmdStr)
|
||||
cmd.Dir = packagePath
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return fmt.Errorf("uninstall command '%s' failed: %s", cmdStr, string(output))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := os.RemoveAll(packagePath); err != nil {
|
||||
return fmt.Errorf("failed to remove package: %w", err)
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ type Manifest struct {
|
||||
Dependencies []string `json:"dependencies"`
|
||||
Build []string `json:"build"`
|
||||
Binaries map[string]BinaryInfo `json:"binaries"`
|
||||
Uninstall []string `json:"uninstall"`
|
||||
}
|
||||
|
||||
func FetchManifest(name string) (*Manifest, error) {
|
||||
|
@ -1,3 +1,3 @@
|
||||
package version
|
||||
|
||||
const CurrentVersion = "1.0.6"
|
||||
const CurrentVersion = "1.0.7"
|
Loading…
x
Reference in New Issue
Block a user