Skip to content

Commit

Permalink
add pnpm for frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
dwu359 committed Oct 30, 2023
1 parent 1d4a279 commit 165a78f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
8 changes: 6 additions & 2 deletions cmd/frontend/add/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ var AddCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
bash_args := []string{"add", args[0]}
if cmd.Flag("dev").Value.String() == "true" {
bash_args = append(bash_args, "--dev")
bash_args = append(bash_args, "-D")
}
if cmd.Flag("yarn").Value.String() == "true" {
frontend.ExecBashCmd("yarn", bash_args...)
} else {
frontend.ExecBashCmd("pnpm", bash_args...)
}
frontend.ExecBashCmd("yarn", bash_args...)
},
}

Expand Down
1 change: 1 addition & 0 deletions cmd/frontend/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var FrontendCmd = &cobra.Command{

func init() {
cmd.RootCmd.AddCommand(FrontendCmd)
FrontendCmd.PersistentFlags().Bool("yarn", false, "Uses yarn instead of pnpm")
}

func ExecBashCmd(name string, args ...string) string {
Expand Down
6 changes: 5 additions & 1 deletion cmd/frontend/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ var InstallCmd = &cobra.Command{
if cmd.Flag("force").Value.String() == "true" {
bash_args = append(bash_args, "--force")
}
frontend.ExecBashCmd("yarn", bash_args...)
if cmd.Flag("yarn").Value.String() == "true" {
frontend.ExecBashCmd("yarn", bash_args...)
} else {
frontend.ExecBashCmd("pnpm", bash_args...)
}
},
}

Expand Down
8 changes: 6 additions & 2 deletions cmd/frontend/remove/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ var RemoveCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
bash_args := []string{"remove", args[0]}
if cmd.Flag("dev").Value.String() == "true" {
bash_args = append(bash_args, "--dev")
bash_args = append(bash_args, "-D")
}
if cmd.Flag("yarn").Value.String() == "true" {
frontend.ExecBashCmd("yarn", bash_args...)
} else {
frontend.ExecBashCmd("pnpm", bash_args...)
}
frontend.ExecBashCmd("yarn", bash_args...)
},
}

Expand Down
7 changes: 6 additions & 1 deletion cmd/frontend/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ var StartCmd = &cobra.Command{
Long: `Starts an instance of the nextjs frontend in the terminal`,
Args: cobra.ExactArgs(0),
Run: func(cmd *cobra.Command, args []string) {
frontend.ExecBashCmd("yarn", "next", "dev", "-p", fmt.Sprintf("%v", cmd.Flag("port").Value))
if cmd.Flag("yarn").Value.String() == "true" {
frontend.ExecBashCmd("yarn", "start", "-p", fmt.Sprintf("%v", cmd.Flag("port").Value))
} else {
frontend.ExecBashCmd("pnpm", "start", "-p", fmt.Sprintf("%v", cmd.Flag("port").Value))
}

},
}

Expand Down

0 comments on commit 165a78f

Please sign in to comment.