Skip to content

Commit

Permalink
Escape bootstrap-version
Browse files Browse the repository at this point in the history
So that a string like `~> 4.0` can be passed without bash transforming `~` to `$HOME`
  • Loading branch information
jcoyne committed Feb 24, 2023
1 parent 45729d4 commit dac353b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/generators/blacklight/assets_generator.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# frozen_string_literal: true
require 'shellwords'

module Blacklight
class AssetsGenerator < Rails::Generators::Base
class_option :'bootstrap-version', type: :string, default: ENV.fetch('BOOTSTRAP_VERSION', '~> 5.1'), desc: "Set the generated app's bootstrap version"

def run_asset_pipeline_specific_generator
generated_options = "--bootstrap-version='#{options[:'bootstrap-version']}'" if options[:'bootstrap-version']
generated_options = "--bootstrap-version='#{Shellwords.escape(options[:'bootstrap-version'])}'" if options[:'bootstrap-version']

generator = if defined?(Propshaft)
'blacklight:assets:propshaft'
Expand Down
3 changes: 2 additions & 1 deletion lib/generators/blacklight/install_generator.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true
require 'shellwords'

module Blacklight
class Install < Rails::Generators::Base
Expand Down Expand Up @@ -35,7 +36,7 @@ def add_solr_wrapper
# Call external generator in AssetsGenerator, so we can
# leave that callable seperately too.
def copy_public_assets
generated_options = "--bootstrap-version='#{options[:'bootstrap-version']}'" if options[:'bootstrap-version']
generated_options = "--bootstrap-version='#{Shellwords.escape(options[:'bootstrap-version'])}'" if options[:'bootstrap-version']

generate "blacklight:assets", generated_options unless options[:'skip-assets']
end
Expand Down

0 comments on commit dac353b

Please sign in to comment.