Skip to content

Commit

Permalink
Allow for overriding build_command
Browse files Browse the repository at this point in the history
  • Loading branch information
zachahn committed Sep 22, 2024
1 parent 30477fd commit 8b4eb0a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/jsbundling/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module Jsbundling
module Tasks
extend self

attr_writer :build_command

def install_command
case tool
when :bun then "bun install"
Expand All @@ -13,6 +15,10 @@ def install_command
end

def build_command
if @build_command
return @build_command
end

case tool
when :bun then "bun run build"
when :yarn then "yarn build"
Expand Down
15 changes: 15 additions & 0 deletions test/tasks_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require "test_helper"
require "jsbundling/tasks"

class TasksTest < ActiveSupport::TestCase
test "override build_command" do
original_build_command = Jsbundling::Tasks.build_command
Jsbundling::Tasks.build_command = "hello there"
assert_equal("hello there", Jsbundling::Tasks.build_command)

Jsbundling::Tasks.build_command = nil
assert_equal(original_build_command, Jsbundling::Tasks.build_command)
ensure
Jsbundling::Tasks.build_command = nil
end
end

0 comments on commit 8b4eb0a

Please sign in to comment.