sighmon / mjml-rails

MJML + ERb/Haml/Slim view template
https://mjml.io
Other
295 stars 64 forks source link

Add support for the Bun package manager #121

Open raybrownco opened 1 month ago

raybrownco commented 1 month ago

My team and I recently started using Bun instead of Yarn/NPM to manage JavaScript packages. The switch was quite painless, but our deploy to Heroku failed with the following error:

ActionView::Template::Error: Couldn't find the MJML 4. binary.. have you run $ npm install mjml? 

11  # @param input [String] The string to transform in html
12  def initialize(input)
13    raise Mjml.mjml_binary_error_string unless Mjml.valid_mjml_binary
14
15    @input = input

After some digging, I realized that we specifically check for MJML in each given package manager:

  def self.valid_mjml_binary
    self.valid_mjml_binary = @@valid_mjml_binary ||
                             check_for_custom_mjml_binary ||
                             check_for_yarn_mjml_binary ||
                             check_for_npm_mjml_binary ||
                             check_for_global_mjml_binary ||
                             check_for_mrml_binary

    return @@valid_mjml_binary if @@valid_mjml_binary

    puts Mjml.mjml_binary_error_string
  end

This PR adds a method to check for the Bun MJML binary.

raybrownco commented 1 month ago

Hmm. Just a few notes:

  1. I'm in the process of testing this locally, so I wouldn't say it's completely ready for review yet.
  2. I see that adding the method to check for Bun has pushed the file over its line length limit. I'll try to abstract the methods related to finding the MJML binary into a utility module and then push my updates up here.
raybrownco commented 6 days ago

@sighmon This one's ready for review!