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

rake: Support task arguments and sh with env hash #765

Merged
merged 2 commits into from
Jan 9, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions gems/rake/13.0/_test/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,23 @@ def create_task
task :test do
ruby "test/unittest.rb"
end

task :test_with_1_arg, :name do |t, args|
value = args[:name]
puts "#{args[:name]}=#{value}"
end

task :test_with_2_args, %i[name1 name2] do |t, args|
args.each do |name, value|
puts "#{name}=#{value}"
end
end

task :test_with_sh do
sh "ruby test/unittest_without_env.rb"

env = { "RACK_ENV" => "test" }
sh env, "ruby test/unittest_with_env.rb"
end
end
end
13 changes: 12 additions & 1 deletion gems/rake/13.0/rake.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ module Rake
include Rake::DSL
end

class Task
end

class TaskArguments
include Enumerable[untyped]

def []: (untyped index) -> untyped
def each: () ?{ (untyped, untyped) -> void } -> void
end

module DSL
private

Expand All @@ -16,12 +26,13 @@ module Rake
def multitask: (*untyped args) ?{ () -> void } -> void
def namespace: (?untyped name) ?{ () -> void } -> void
def rule: (*untyped args) ?{ () -> void } -> void
def task: (*untyped args) ?{ () -> void } -> void
def task: (*untyped args) ?{ (Rake::Task, Rake::TaskArguments) -> void } -> void
end
end

module FileUtils
def sh: (*String cmd, **untyped options) ?{ (bool, Process::Status) -> void } -> void
| (Hash[String, String] env, *String cmd, **untyped options) ?{ (bool, Process::Status) -> void } -> void
def ruby: (*String args, **untyped options) ?{ (bool, Process::Status) -> void } -> void
def safe_ln: (*untyped args, **untyped options) -> void
def split_all: (String path) -> Array[String]
Expand Down
Loading