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,17 +143,19 @@ module ExecJS
|
|||
|
||||
if ExecJS.windows?
|
||||
def exec_runtime(filename)
|
||||
command = binary.split(" ") << filename
|
||||
path = Dir::Tmpname.create(['execjs', 'json']) {}
|
||||
begin
|
||||
command = binary.split(" ") << filename
|
||||
`#{shell_escape(*command)} 2>&1 > #{path}`
|
||||
output = File.open(path, 'rb', @popen_options) { |f| f.read }
|
||||
ensure
|
||||
File.unlink(path) if path
|
||||
end
|
||||
|
||||
Dir::Tmpname.create(['execjs', 'json']) do |output|
|
||||
`#{shell_escape(*command)} 2>&1 > #{output}`
|
||||
output = File.open(output, 'rb', @popen_options) { |f| f.read }
|
||||
|
||||
if $?.success?
|
||||
return output
|
||||
else
|
||||
raise RuntimeError, output
|
||||
end
|
||||
if $?.success?
|
||||
output
|
||||
else
|
||||
raise RuntimeError, output
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -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