Skip to content

Commit 1f31ec4

Browse files
authored
Merge pull request #45 from ntkme/exec-array
Use array args instead of string args for system command
2 parents 660ea09 + 2201587 commit 1f31ec4

File tree

6 files changed

+27
-12
lines changed

6 files changed

+27
-12
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jobs:
99
- "3.0"
1010
- "3.1"
1111
- "3.2"
12+
- "3.3"
1213
gemfile:
1314
- Gemfile
1415
- gemfiles/rails_7_0_propshaft.gemfile
@@ -17,6 +18,11 @@ jobs:
1718
- gemfiles/rails_7_0_sprockets.gemfile
1819
- gemfiles/rails_7_1_sprockets.gemfile
1920
- gemfiles/rails_main_sprockets.gemfile
21+
exclude:
22+
- ruby-version: "3.0"
23+
gemfile: gemfiles/rails_main_propshaft.gemfile
24+
- ruby-version: "3.0"
25+
gemfile: gemfiles/rails_main_sprockets.gemfile
2026
continue-on-error: [ false ]
2127

2228
name: ${{ format('Tests (Ruby {0}, {1})', matrix.ruby-version, matrix.gemfile) }}

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.flat_map(&:split)
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)