Files
pmg/cmd/npm/npm.go
T

32 lines
689 B
Go
Raw Normal View History

2025-04-30 14:26:38 +05:30
package npm
import (
_ "embed"
"github.com/safedep/dry/log"
"github.com/safedep/pmg/config"
"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 {
config, err := config.FromContext(cmd.Context())
2025-04-30 14:26:38 +05:30
if err != nil {
ui.Fatalf("Failed to get config: %s", err)
2025-04-30 14:26:38 +05:30
}
err = executeNpmFlow(cmd.Context(), config, args)
if err != nil {
log.Errorf("Failed to execute npm flow: %s", err)
2025-04-30 14:26:38 +05:30
}
return nil
},
}
}