[rubygems/rubygems] allow bat
files to be created alongside with script files on Windows
https://github.com/rubygems/rubygems/commit/ed5b847f03
This commit is contained in:
parent
e18fb1281a
commit
55f2917cfd
@ -235,10 +235,20 @@ module Spec
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_file(path, contents = "")
|
def create_file(path, contents = "")
|
||||||
|
contents = strip_whitespace(contents)
|
||||||
path = Pathname.new(path).expand_path(bundled_app) unless path.is_a?(Pathname)
|
path = Pathname.new(path).expand_path(bundled_app) unless path.is_a?(Pathname)
|
||||||
path.dirname.mkpath
|
path.dirname.mkpath
|
||||||
File.open(path.to_s, "w") do |f|
|
path.write(contents)
|
||||||
f.puts strip_whitespace(contents)
|
|
||||||
|
# if the file is a script, create respective bat file on Windows
|
||||||
|
if contents.start_with?("#!")
|
||||||
|
path.chmod(0o755)
|
||||||
|
if Gem.win_platform?
|
||||||
|
path.sub_ext(".bat").write <<~SCRIPT
|
||||||
|
@ECHO OFF
|
||||||
|
@"ruby.exe" "%~dpn0" %*
|
||||||
|
SCRIPT
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user