torba-rb/torba

Auto pack in development

JanStevens opened this issue · 4 comments

We used to have bower and one thing devs always forget after pulling from master is to do a bower install.

With torba I automated the process by including the following file in an initializer:

# Auto pack when in development, normally assets:precompile takes care of this
class TorbaAutoPack
  def self.start!
    Torba.verify
  rescue Torba::Errors::MissingPackages
    Rails.logger.error "Assets not packed yet, packing..."
    Torba.pack
    Rails.logger.error 'Done asset packing, booting...'
  rescue Errors::NothingToImport => e
    Rails.logger.error "Couldn't import an asset(-s) '#{e.path}' from import list in '#{e.package}'."
    Rails.logger.error "Check for typos."
    Rails.logger.error "Make sure that the path has trailing '/' if its a directory."
  rescue Errors::AssetNotFound => e
    Rails.logger.error "Couldn't find an asset with path '#{e.message}'."
    Rails.logger.error "Make sure that you've imported all image/font assets mentioned in a stylesheet(-s)."
  end
end

TorbaAutoPack.start! if Rails.env.development?

Would be awesome if we could include this in the torba/rails file when we are on development

But verify only throws an error and does not pack

With this you first verify if an error is found it automatically pack, this way another dev does not have to run rake torba:pack manually

I'd like Torba to behave like Bundler does.
When a gem is missing, Bundler throws an error and stops.

Allright fair enough 👍