Skip to content
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

Handle tailwindcss:watch[always] #262

Merged
merged 1 commit into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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