Files
pmg/cmd/npm/npm.go
T

31 lines
658 B
Go
Raw Normal View History

2025-04-30 14:26:38 +05:30
package npm
import (
_ "embed"
2025-05-14 16:09:29 +05:30
"github.com/safedep/pmg/config"
2025-05-15 14:00:18 +05:30
"github.com/safedep/pmg/internal/ui"
2025-04-30 14:26:38 +05:30
"github.com/spf13/cobra"
)
func NewNpmCommand() *cobra.Command {
return &cobra.Command{
2025-04-30 14:26:38 +05:30
Use: "npm [action] [package]",
Short: "Guard npm package manager",
2025-04-30 14:26:38 +05:30
DisableFlagParsing: true,
RunE: func(cmd *cobra.Command, args []string) error {
2025-05-14 16:09:29 +05:30
config, err := config.FromContext(cmd.Context())
if err != nil {
2025-05-15 14:00:18 +05:30
ui.Fatalf("Failed to get config: %s", err)
2025-05-14 16:09:29 +05:30
}
2025-05-15 14:00:18 +05:30
err = executeNpmFlow(cmd.Context(), config, args)
if err != nil {
ui.Fatalf("Failed to execute npm flow: %s", err)
}
return nil
2025-04-30 14:26:38 +05:30
},
}
}