-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use array args instead of string args for system command #45
Conversation
exclude: | ||
- ruby-version: "3.0" | ||
gemfile: gemfiles/rails_main_propshaft.gemfile | ||
- ruby-version: "3.0" | ||
gemfile: gemfiles/rails_main_sprockets.gemfile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main branch no longer install on ruby 3.0, therefore exclude them from the test.
end | ||
|
||
def dartsass_build_options | ||
Rails.application.config.dartsass.build_options | ||
Rails.application.config.dartsass.build_options.flat_map(&:split) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
split
is used for compatibility with <=0.5.0
, where build_options
are simply concatenated strings:
--option
(with a space prefix) will become["--option"]
.--option1 --option2
will become["--option1", "--option2"]
end | ||
|
||
def dartsass_compile_command | ||
"#{EXEC_PATH} #{dartsass_build_options} #{dartsass_load_paths} #{dartsass_build_mapping}" | ||
[ RbConfig.ruby, EXEC_PATH ].concat(dartsass_build_options).concat(dartsass_load_paths).concat(dartsass_build_mapping) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding RbConfig.ruby
so that it works on windows as well.
end | ||
|
||
namespace :dartsass do | ||
desc "Build your Dart Sass CSS" | ||
task build: :environment do | ||
system dartsass_compile_command, exception: true | ||
system(*dartsass_compile_command, exception: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The array form of system
does not invoke a shell. It invoke the binary directly, therefore it is faster and safer.
@dhh I have added some comments explaining the changes here. Would you mind take a look when you get a chance? Thanks. |
Looks good! |
This PR has the following changes: