Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
Fail on npm/node issues during buffalo new fixes #1368
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates committed Oct 24, 2018
1 parent f5c9fe5 commit d6644b3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
14 changes: 8 additions & 6 deletions generators/assets/webpack/webpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import (
"path/filepath"

"github.com/gobuffalo/buffalo/generators"
"github.com/gobuffalo/buffalo/generators/assets/standard"
"github.com/gobuffalo/makr"
"github.com/gobuffalo/packr"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

// TemplateBox contains all templates needed for the webpack generator
Expand All @@ -22,11 +20,10 @@ var BinPath = filepath.Join("node_modules", ".bin", "webpack")
func (w Generator) Run(root string, data makr.Data) error {
g := makr.New()

// if there's no npm, return!
if _, err := exec.LookPath("npm"); err != nil {
logrus.Info("Could not find npm. Skipping webpack generation.")
// if there's no node, return!

return standard.Run(root, data)
if _, err := exec.LookPath("node"); err != nil {
return errors.New("could not find node installed. either install node or run with the --skip-webpack flag")
}

command := "yarnpkg"
Expand All @@ -40,6 +37,11 @@ func (w Generator) Run(root string, data makr.Data) error {
}
}

// if there's no npm, return!
if _, err := exec.LookPath("npm"); err != nil {
return errors.New("could not find npm installed. either install node or run with the --skip-webpack flag")
}

files, err := generators.FindByBox(TemplateBox)
if err != nil {
return errors.WithStack(err)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/gobuffalo/buffalo-pop v1.1.3
github.com/gobuffalo/envy v1.6.5
github.com/gobuffalo/events v1.1.3
github.com/gobuffalo/fizz v1.0.13 // indirect
github.com/gobuffalo/flect v0.0.0-20181019110701-3d6f0b585514
github.com/gobuffalo/genny v0.0.0-20181022180253-ea079e3a44ad
github.com/gobuffalo/github_flavored_markdown v1.0.5
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ github.com/gobuffalo/events v1.1.3 h1:TQop86GldHCxlW8Pdyyyzw7KqXROT0V8bkuWrnhta6
github.com/gobuffalo/events v1.1.3/go.mod h1:9yPGWYv11GENtzrIRApwQRMYSbUgCsZ1w6R503fCfrk=
github.com/gobuffalo/fizz v1.0.12 h1:JJOkmlStog5AiBL434UoGMJ896p3MnTnzedFVaZSF3k=
github.com/gobuffalo/fizz v1.0.12/go.mod h1:C0sltPxpYK8Ftvf64kbsQa2yiCZY4RZviurNxXdAKwc=
github.com/gobuffalo/fizz v1.0.13 h1:26P6k7Qlf6DJMB8D/0L1GLOgG2JVBItm8cP8cNNm71w=
github.com/gobuffalo/fizz v1.0.13/go.mod h1:v83LCLNuzL7GCwS5bbN6tZhQa+aKtfz8T+OoJewHaLw=
github.com/gobuffalo/flect v0.0.0-20180907193754-dc14d8acaf9f/go.mod h1:rCiQgmAE4axgBNl3jZWzS5rETRYTGOsrixTRaCPzNdA=
github.com/gobuffalo/flect v0.0.0-20181002182613-4571df4b1daf/go.mod h1:rCiQgmAE4axgBNl3jZWzS5rETRYTGOsrixTRaCPzNdA=
github.com/gobuffalo/flect v0.0.0-20181007231023-ae7ed6bfe683/go.mod h1:rCiQgmAE4axgBNl3jZWzS5rETRYTGOsrixTRaCPzNdA=
Expand Down

0 comments on commit d6644b3

Please sign in to comment.