Skip to content

Commit

Permalink
add package update keybinding
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed Apr 16, 2020
1 parent ae57b78 commit 8afc6cc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/gui/keybindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,12 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Handler: gui.wrappedPackageHandler(gui.handleOpenPackageConfig),
Description: "open package.json",
},
{
ViewName: "packages",
Key: gui.getKey("universal.update"),
Handler: gui.wrappedPackageHandler(gui.handlePackageUpdate),
Description: fmt.Sprintf("%s package", utils.ColoredString("`npm update`", color.FgYellow)),
},
{
ViewName: "scripts",
Key: gui.getKey("universal.select"),
Expand Down
11 changes: 11 additions & 0 deletions pkg/gui/packages_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,17 @@ func (gui *Gui) handleInstall(pkg *commands.Package) error {
return gui.newMainCommand(cmdStr, pkg.ID(), newMainCommandOptions{})
}

func (gui *Gui) handlePackageUpdate(pkg *commands.Package) error {
var cmdStr string
if pkg == gui.currentPackage() {
cmdStr = "npm update"
} else {
cmdStr = "npm update --prefix " + pkg.Path
}

return gui.newMainCommand(cmdStr, pkg.ID(), newMainCommandOptions{})
}

func (gui *Gui) handleBuild(pkg *commands.Package) error {
var cmdStr string
if pkg == gui.currentPackage() {
Expand Down

0 comments on commit 8afc6cc

Please # to comment.