Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22395921
exec.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
748 B
Referenced Files
None
Subscribers
None
exec.ts
View Options
/* eslint-disable no-console */
import
{
spawn
}
from
"child_process"
;
export
async
function
exec
(
program
:
string
,
args
:
string
[]
)
:
Promise
<
{
stderr
:
string
;
stdout
:
string
;
exitCode
:
number
}
>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
stdout
=
""
;
let
stderr
=
""
;
const
process
=
spawn
(
program
,
args
);
process
.
stdout
.
on
(
"data"
,
(
data
:
Buffer
)
=>
(
stdout
+=
data
.
toString
())
);
process
.
stderr
.
on
(
"data"
,
(
data
:
Buffer
)
=>
(
stderr
+=
data
.
toString
())
);
process
.
on
(
"close"
,
(
exitCode
)
=>
{
if
(
exitCode
===
0
)
{
resolve
({
stdout
,
stderr
,
exitCode
});
}
else
{
console
.
error
([
program
,
...
args
].
join
(
" "
));
console
.
error
(
stderr
);
reject
({
stdout
,
stderr
,
exitCode
});
}
});
});
}
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Fri, Nov 27, 16:30 (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1200223
Default Alt Text
exec.ts (748 B)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline