binaryen 1.1.6.2 → 1.1.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/binaryen/command.rb +15 -67
- data/lib/binaryen/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae90a4e59e6f813687257623ab4d4a35633c9409de5459101d8080d65fe1fdf1
|
4
|
+
data.tar.gz: 20c161cfa875c14801d03ae2f7a43f5342a0e0a8b9c70f9d9e2d1f44b722f3e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74f7b3010d06316d25eb8b3e74fc2fd33b60f50fcd3bd6db83db8b11c135e003f49f460779e02992e0826a86240b220d3c8e1c82e56361e1e6d054cc7b172679
|
7
|
+
data.tar.gz: 90de5bc2e078f8083116a8dc8244e3807185ff35c1697ef210070bcd4f01d7bf730f13fa1731f479b06032dcc778109faf848a0daa2da0915ab7fe18b033a3e0
|
data/lib/binaryen/command.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "English"
|
4
|
-
require "shellwords"
|
5
3
|
require "timeout"
|
4
|
+
require "posix/spawn"
|
6
5
|
|
7
6
|
module Binaryen
|
8
7
|
# Wrapper around a binaryen executable command with a timeout and streaming IO.
|
@@ -42,76 +41,25 @@ module Binaryen
|
|
42
41
|
end
|
43
42
|
|
44
43
|
def run(*arguments, stdin: nil, stderr: File::NULL)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
wait_or_kill(pid, timeout_checker)
|
54
|
-
|
55
|
-
output
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
def write_to_pipe(pipe, stdin, timeout_checker)
|
61
|
-
offset = 0
|
62
|
-
length = stdin.bytesize
|
63
|
-
|
64
|
-
while offset < length
|
65
|
-
remaining_time = timeout_checker.check!
|
66
|
-
|
67
|
-
if IO.select(nil, [pipe], nil, remaining_time)
|
68
|
-
written = pipe.write_nonblock(stdin.byteslice(offset, length), exception: false)
|
69
|
-
offset += written if written.is_a?(Integer)
|
70
|
-
else
|
71
|
-
raise Timeout::Error, "Command timed out"
|
72
|
-
end
|
44
|
+
args = build_arguments(*arguments)
|
45
|
+
child = POSIX::Spawn::Child.new(@cmd, *args, input: stdin, timeout: @timeout)
|
46
|
+
if child.status && !child.status.success?
|
47
|
+
err_io = stderr.is_a?(String) ? File.open(stderr, "w") : stderr
|
48
|
+
err_io.binmode
|
49
|
+
err_io.write(child.err)
|
50
|
+
err_io.rewind
|
51
|
+
raise NonZeroExitStatus, "command exited with non-zero status: #{child.status}"
|
73
52
|
end
|
74
53
|
|
75
|
-
|
54
|
+
child.out
|
55
|
+
rescue POSIX::Spawn::TimeoutExceeded => e
|
56
|
+
raise Timeout::Error, e.message
|
76
57
|
end
|
77
58
|
|
78
|
-
|
79
|
-
output = +""
|
80
|
-
|
81
|
-
while (result = pipe.read_nonblock(8192, exception: false))
|
82
|
-
remaining_time = timeout_checker.check!
|
83
|
-
raise Timeout::Error, "Command timed out" if remaining_time <= 0
|
84
|
-
|
85
|
-
case result
|
86
|
-
when :wait_readable
|
87
|
-
IO.select([pipe], nil, nil, remaining_time)
|
88
|
-
when nil
|
89
|
-
break
|
90
|
-
else
|
91
|
-
output << result
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
output
|
96
|
-
end
|
97
|
-
|
98
|
-
def wait_or_kill(pid, timeout_checker)
|
99
|
-
loop do
|
100
|
-
remaining_time = timeout_checker.check!
|
101
|
-
raise Timeout::Error, "timed out waiting on process" if remaining_time <= 0
|
102
|
-
|
103
|
-
if (_, status = Process.wait2(pid, Process::WNOHANG))
|
104
|
-
raise Binaryen::NonZeroExitStatus, "command exited with status #{status.exitstatus}" if status.exitstatus != 0
|
105
|
-
|
106
|
-
return true
|
107
|
-
else
|
108
|
-
sleep(0.1)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
59
|
+
private
|
112
60
|
|
113
|
-
def
|
114
|
-
|
61
|
+
def build_arguments(*arguments)
|
62
|
+
arguments + @default_args
|
115
63
|
end
|
116
64
|
|
117
65
|
def command_path(cmd, ignore_missing)
|
data/lib/binaryen/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: binaryen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.6.
|
4
|
+
version: 1.1.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
12
|
-
dependencies:
|
11
|
+
date: 2023-12-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: posix-spawn
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.3'
|
13
27
|
description:
|
14
28
|
email:
|
15
29
|
- gems@shopify.com
|