Skip to content

Commit

Permalink
Merge pull request #262 from GoodForOneFare/watch-always
Browse files Browse the repository at this point in the history
Handle `tailwindcss:watch[always]`
  • Loading branch information
rafaelfranca committed Apr 20, 2023
2 parents 592bd4d + f44a6db commit 3e95f8f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/tailwindcss/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ def compile_command(debug: false, **kwargs)
end
end

def watch_command(poll: false, **kwargs)
def watch_command(always: false, poll: false, **kwargs)
compile_command(**kwargs).tap do |command|
command << "-w"
command << "always" if always
command << "-p" if poll
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/tasks/build.rake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ namespace :tailwindcss do
task watch: :environment do |_, args|
debug = args.extras.include?("debug")
poll = args.extras.include?("poll")
command = Tailwindcss::Commands.watch_command(debug: debug, poll: poll)
always = args.extras.include?("always")
command = Tailwindcss::Commands.watch_command(always: always, debug: debug, poll: poll)
puts command.inspect if args.extras.include?("verbose")
system(*command)
end
Expand Down
7 changes: 7 additions & 0 deletions test/lib/tailwindcss/commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,15 @@ def mock_local_tailwindcss_install
assert_kind_of(Array, actual)
assert_equal(executable, actual.first)
assert_includes(actual, "-w")
refute_includes(actual, "always")
assert_includes(actual, "-p")
assert_includes(actual, "--minify")

actual = Tailwindcss::Commands.watch_command(exe_path: dir, always: true)
assert_kind_of(Array, actual)
assert_equal(executable, actual.first)
assert_includes(actual, "-w")
assert_includes(actual, "always")
end
end
end
Expand Down

0 comments on commit 3e95f8f

Please sign in to comment.