You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using Node.js as a plugin engine for a Rust program, using stdin and stdout to communicate with the child process.
I need to get node to run my glue code so the parent/child can communicate.
Generally, Node can accept a program via stdin, e.g.
echo "console.log(42)" | node
> 42
However when this is used by a parent program to inject glue code, stdin must be closed for Node.js to evaluate. This means stdin will no longer available to talk with the child process.
I have tried node -e "eval(atob('<base64-ecoded-string>'))" but this will likely fail because the script will be too long. Unfortunately (I guess for security reasons) -e is not available via NODE_OPTIONS so the only way to use Node as a plugin engine is to write a file to disk and tell Node to run that file.
Not terrible, but a but cumbersome.
Would be great if there was an alternative approach to using Node.js as a plugin runtime
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am using Node.js as a plugin engine for a Rust program, using
stdin
andstdout
to communicate with the child process.I need to get node to run my glue code so the parent/child can communicate.
Generally, Node can accept a program via stdin, e.g.
However when this is used by a parent program to inject glue code,
stdin
must be closed for Node.js to evaluate. This meansstdin
will no longer available to talk with the child process.I have tried
node -e "eval(atob('<base64-ecoded-string>'))"
but this will likely fail because the script will be too long. Unfortunately (I guess for security reasons)-e
is not available viaNODE_OPTIONS
so the only way to use Node as a plugin engine is to write a file to disk and tell Node to run that file.Not terrible, but a but cumbersome.
Would be great if there was an alternative approach to using Node.js as a plugin runtime
Beta Was this translation helpful? Give feedback.
All reactions