Skip to content

Commit

Permalink
add hook-invoke subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
ImSingee committed Sep 6, 2023
1 parent bf958f9 commit 635138c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/kitty/kitty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ if [ -z "$kitty_skip_init" ]; then
fi
done

export PATH="$(pwd)/.kitty/.bin:$PATH"
eval "$(kitty hook-invoke $hook_name 1)"

readonly kitty_skip_init=1
export kitty_skip_init

Expand Down
21 changes: 21 additions & 0 deletions cmd/kitty/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,27 @@ func main() {
RunE: func(cmd *cobra.Command, args []string) error {
pp.Println("`@extension` is not a real command.\nIt just means you can use `kitty @xxx` to run some extension.\nFor example, if you want to run `lint-staged` extension, run `kitty @lint-staged`.")

return nil
},
},
&cobra.Command{
Use: "hook-invoke <hook-name> <version>",
Args: cobra.MinimumNArgs(2),
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
hookName := args[0]
hookVersion := args[1]

if hookVersion != "1" {
fmt.Println(`echo "Your kitty version is too low, please upgrade"
exit 1`)
return nil
}

fmt.Println(`export KITTY_VERSION=` + version)

_ = hookName

return nil
},
},
Expand Down

0 comments on commit 635138c

Please sign in to comment.