File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -107,3 +107,31 @@ task :release => :compile do
107107 end
108108 end
109109end
110+
111+ namespace :local do
112+ desc "show help"
113+ task :version do
114+ require_relative 'mrblib/mruby-cli/version'
115+ puts "mruby-cli #{ MRubyCLI ::Version ::VERSION } "
116+ end
117+ end
118+
119+ def is_in_a_docker_container?
120+ `grep -q docker /proc/self/cgroup`
121+ $?. success?
122+ end
123+
124+ Rake . application . tasks . each do |task |
125+ next if ENV [ "MRUBY_CLI_LOCAL" ]
126+ unless task . name . start_with? ( "local:" )
127+ # Inspired by rake-hooks
128+ # https://github.com/guillermo/rake-hooks
129+ old_task = Rake . application . instance_variable_get ( '@tasks' ) . delete ( task . name )
130+ desc old_task . full_comment
131+ task old_task . name => old_task . prerequisites do
132+ abort ( "Not running in docker, you should type \" docker-compose run <task>\" ." ) \
133+ unless is_in_a_docker_container?
134+ old_task . invoke
135+ end
136+ end
137+ end
Original file line number Diff line number Diff line change @@ -382,6 +382,34 @@ def clean_env(envs)
382382task :clean do
383383 sh "rake deep_clean"
384384end
385+
386+ namespace :local do
387+ desc "show help"
388+ task :version do
389+ require_relative 'mrblib/mruby-cli/version'
390+ puts "mruby-cli \# {MRubyCLI::Version::VERSION}"
391+ end
392+ end
393+
394+ def is_in_a_docker_container?
395+ `grep -q docker /proc/self/cgroup`
396+ $?.success?
397+ end
398+
399+ Rake.application.tasks.each do |task|
400+ next if ENV["MRUBY_CLI_LOCAL"]
401+ unless task.name.start_with?("local:")
402+ # Inspired by rake-hooks
403+ # https://github.com/guillermo/rake-hooks
404+ old_task = Rake.application.instance_variable_get('@tasks').delete(task.name)
405+ desc old_task.full_comment
406+ task old_task.name => old_task.prerequisites do
407+ abort("Not running in docker, you should type \\ "docker-compose run <task>\\ ".") \
408+ unless is_in_a_docker_container?
409+ old_task.invoke
410+ end
411+ end
412+ end
385413RAKEFILE
386414 end
387415 end
You can’t perform that action at this time.
0 commit comments