feat(zsh): implement PlanForce
This commit is contained in:
@@ -3,7 +3,6 @@ package zsh
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -133,5 +132,42 @@ func (m Module) Verify(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func (m Module) PlanForce(ctx context.Context) (module.Plan, error) {
|
||||
return module.Plan{}, errors.New("PlanForce not implemented")
|
||||
actions := []module.Action{{
|
||||
Description: "pacman -S (force) zsh",
|
||||
Kind: module.ActionPackageInstall,
|
||||
Exec: func(ctx context.Context) error { return m.pm.Reinstall(ctx, []string{"zsh"}) },
|
||||
}}
|
||||
actions = append(actions, module.Action{
|
||||
Description: "reclone oh-my-zsh from " + m.cfg.OhMyZshRepo + " (force)",
|
||||
Kind: module.ActionGitClone,
|
||||
Exec: func(ctx context.Context) error {
|
||||
omz, err := omzHome()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.RemoveAll(omz); err != nil {
|
||||
return err
|
||||
}
|
||||
return m.git.Clone(ctx, m.cfg.OhMyZshRepo, omz)
|
||||
},
|
||||
})
|
||||
for _, p := range m.cfg.Plugins {
|
||||
p := p
|
||||
actions = append(actions, module.Action{
|
||||
Description: "reclone plugin " + p.Name + " (force)",
|
||||
Kind: module.ActionGitClone,
|
||||
Exec: func(ctx context.Context) error {
|
||||
omz, err := omzHome()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dest := filepath.Join(omz, "custom", "plugins", p.Name)
|
||||
if err := os.RemoveAll(dest); err != nil {
|
||||
return err
|
||||
}
|
||||
return m.git.Clone(ctx, p.Repo, dest)
|
||||
},
|
||||
})
|
||||
}
|
||||
return module.Plan{Actions: actions}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user