Skip to content

Commit c27dbe1

Browse files
committed
Use array args instead of string args for system command
1 parent 660ea09 commit c27dbe1

File tree

5 files changed

+21
-12
lines changed

5 files changed

+21
-12
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,22 @@ Rails.application.config.dartsass.builds = {
3535

3636
The hash key is the relative path to a Sass file in `app/assets/stylesheets/` and the hash value will be the name of the file output to `app/assets/builds/`.
3737

38+
If both the hash key and the hash value are directories instead of files, it configures a directory to directory compliation, which compiles all public Sass files whose filenames do not start with underscore (`_`).
39+
40+
```ruby
41+
# config/initializers/dartsass.rb
42+
Rails.application.config.dartsass.builds = {
43+
"." => "."
44+
}
45+
```
46+
3847
## Configuring build options
3948

40-
By default, sass is invoked with `--style=compressed --no-source-map`. You can adjust these options by overwriting `Rails.application.config.dartsass.build_options`.
49+
By default, sass is invoked with `["--style=compressed", "--no-source-map"]`. You can adjust these options by overwriting `Rails.application.config.dartsass.build_options`.
4150

4251
```ruby
4352
# config/initializers/dartsass.rb
44-
Rails.application.config.dartsass.build_options << " --quiet-deps"
53+
Rails.application.config.dartsass.build_options << "--no-charset" << "--quiet-deps"
4554
```
4655

4756
## Importing assets from gems

dartsass-rails.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
1414
"rubygems_mfa_required" => "true"
1515
}
1616

17-
spec.files = Dir["{lib,exe}/**/*", "MIT-LICENSE", "LICENSE-DEPENDENCIES", "Rakefile", "README.md"]
17+
spec.files = Dir["{lib,exe}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
1818
spec.bindir = "exe"
1919
spec.executables << "dartsass"
2020

lib/dartsass/engine.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ module Dartsass
44
class Engine < ::Rails::Engine
55
config.dartsass = ActiveSupport::OrderedOptions.new
66
config.dartsass.builds = { "application.scss" => "application.css" }
7-
config.dartsass.build_options = "--style=compressed --no-source-map"
7+
config.dartsass.build_options = ["--style=compressed", "--no-source-map"]
88
end
99
end

lib/tasks/build.rake

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@ CSS_BUILD_PATH = Rails.root.join("app/assets/builds")
44

55
def dartsass_build_mapping
66
Rails.application.config.dartsass.builds.map { |input, output|
7-
"#{Shellwords.escape(CSS_LOAD_PATH.join(input))}:#{Shellwords.escape(CSS_BUILD_PATH.join(output))}"
8-
}.join(" ")
7+
"#{CSS_LOAD_PATH.join(input)}:#{CSS_BUILD_PATH.join(output)}"
8+
}
99
end
1010

1111
def dartsass_build_options
12-
Rails.application.config.dartsass.build_options
12+
Rails.application.config.dartsass.build_options.map(&:strip)
1313
end
1414

1515
def dartsass_load_paths
16-
[ CSS_LOAD_PATH ].concat(Rails.application.config.assets.paths).map { |path| "--load-path #{Shellwords.escape(path)}" }.join(" ")
16+
[ CSS_LOAD_PATH ].concat(Rails.application.config.assets.paths).flat_map { |path| ["--load-path", path.to_s] }
1717
end
1818

1919
def dartsass_compile_command
20-
"#{EXEC_PATH} #{dartsass_build_options} #{dartsass_load_paths} #{dartsass_build_mapping}"
20+
[ RbConfig.ruby, EXEC_PATH ].concat(dartsass_build_options).concat(dartsass_load_paths).concat(dartsass_build_mapping)
2121
end
2222

2323
namespace :dartsass do
2424
desc "Build your Dart Sass CSS"
2525
task build: :environment do
26-
system dartsass_compile_command, exception: true
26+
system(*dartsass_compile_command, exception: true)
2727
end
2828

2929
desc "Watch and build your Dart Sass CSS on file changes"
3030
task watch: :environment do
31-
system "#{dartsass_compile_command} -w", exception: true
31+
system(*dartsass_compile_command, "--watch", exception: true)
3232
end
3333
end
3434

lib/tasks/install.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace :dartsass do
22
desc "Install Dart Sass into the app"
33
task :install do
4-
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/dartsass.rb", __dir__)}", exception: true
4+
system RbConfig.ruby, "./bin/rails", "app:template", "LOCATION=#{File.expand_path("../install/dartsass.rb", __dir__)}", exception: true
55
end
66
end

0 commit comments

Comments
 (0)