mirror of
https://github.com/rails/execjs
synced 2023-03-27 23:21:20 -04:00
Cleanup tmp output
This commit is contained in:
parent
b2afd3155f
commit
87966b6787
1 changed files with 12 additions and 20 deletions
|
@ -143,19 +143,21 @@ module ExecJS
|
|||
|
||||
if ExecJS.windows?
|
||||
def exec_runtime(filename)
|
||||
path = Dir::Tmpname.create(['execjs', 'json']) {}
|
||||
begin
|
||||
command = binary.split(" ") << filename
|
||||
|
||||
Dir::Tmpname.create(['execjs', 'json']) do |output|
|
||||
`#{shell_escape(*command)} 2>&1 > #{output}`
|
||||
output = File.open(output, 'rb', @popen_options) { |f| f.read }
|
||||
`#{shell_escape(*command)} 2>&1 > #{path}`
|
||||
output = File.open(path, 'rb', @popen_options) { |f| f.read }
|
||||
ensure
|
||||
File.unlink(path) if path
|
||||
end
|
||||
|
||||
if $?.success?
|
||||
return output
|
||||
output
|
||||
else
|
||||
raise RuntimeError, output
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def shell_escape(*args)
|
||||
# see http://technet.microsoft.com/en-us/library/cc723564.aspx#XSLTsection123121120120
|
||||
|
@ -164,16 +166,6 @@ module ExecJS
|
|||
arg
|
||||
}.join(" ")
|
||||
end
|
||||
|
||||
# See Tempfile.create on Ruby 2.1
|
||||
def create_tempfile(basename)
|
||||
tmpfile = nil
|
||||
Dir::Tmpname.create(basename) do |tmpname|
|
||||
mode = File::WRONLY | File::CREAT | File::EXCL
|
||||
tmpfile = File.open(tmpname, mode, 0600)
|
||||
end
|
||||
tmpfile
|
||||
end
|
||||
else
|
||||
def exec_runtime(filename)
|
||||
io = IO.popen(binary.split(' ') << filename, @popen_options.merge({err: [:child, :out]}))
|
||||
|
|
Loading…
Reference in a new issue