rails / cssbundling-rails

Bundle and process CSS in Rails with Tailwind, PostCSS, and Sass via Node.js.
MIT License
579 stars 83 forks source link

If build command fails raise a helpful exception #31

Closed phawk closed 3 years ago

phawk commented 3 years ago

Fixes #28

I’m not sure convention wise if there are better ways of outputting this error message, let me know and I can make adjustments.

Once sorted I’ll PR a similar change into jsbundling-rails.

dhh commented 3 years ago

Does this swallow the original error? Or that'll just get shown as part of standard out? What does the console output look like in its entirety?

phawk commented 3 years ago

Nope it doesn’t swallow the yarn output, system returns false if the exit code was > 0.

Output when pushing to heroku without the node.js buildpack:

remote:        Bundle complete! 27 Gemfile dependencies, 84 gems now installed.
remote:        Gems in the groups 'development' and 'test' were not installed.
remote:        Bundled gems are installed into `./vendor/bundle`
remote:        Bundle completed (33.05s)
remote:        Cleaning up the bundler cache.
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        Yarn executable was not detected in the system.
remote:        Download Yarn at https://yarnpkg.com/en/docs/install
remote:        Yarn executable was not detected in the system.
remote:        Download Yarn at https://yarnpkg.com/en/docs/install
remote:        rake aborted!
remote:        cssbundling-rails: Command css:build failed, ensure yarn is installed and `yarn build:css` runs without errors
remote:        /tmp/build_54c5dff2/vendor/bundle/ruby/3.0.0/bundler/gems/cssbundling-rails-ae6760770765/lib/tasks/cssbundling/build.rake:5:in `block (2 levels) in <main>'
remote:        /tmp/build_54c5dff2/vendor/bundle/ruby/3.0.0/gems/sentry-ruby-core-4.7.3/lib/sentry/rake.rb:23:in `block in execute'
remote:        /tmp/build_54c5dff2/vendor/bundle/ruby/3.0.0/gems/sentry-ruby-core-4.7.3/lib/sentry/hub.rb:158:in `with_background_worker_disabled'
remote:        /tmp/build_54c5dff2/vendor/bundle/ruby/3.0.0/gems/sentry-ruby-core-4.7.3/lib/sentry/rake.rb:22:in `execute'
remote:        Tasks: TOP => assets:precompile => css:build
remote:        (See full trace by running task with --trace)
remote: 
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !       Push rejected to anthem-test.
remote: 
To https://git.heroku.com/anthem-test.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/anthem-test.git'