graaljs icon indicating copy to clipboard operation
graaljs copied to clipboard

Run code before launching REPL

Open Melab opened this issue 3 years ago • 4 comments

On Node.js, I can run JavaScript code before the interactive is launched by using --i in conjunction with --eval. If such a feature is not already available with the GraalVM JavaScript shell, then it should be added.

Melab avatar Jan 09 '22 02:01 Melab

Hi @Melab. Do you mean like this?

xxx@xxx-mac ~ % java -version
openjdk version "11.0.13" 2021-10-19
OpenJDK Runtime Environment GraalVM CE 21.3.0 (build 11.0.13+7-jvmci-21.3-b05)
OpenJDK 64-Bit Server VM GraalVM CE 21.3.0 (build 11.0.13+7-jvmci-21.3-b05, mixed mode, sharing)
xxx@xxx-mac ~ % node -v
v14.17.6
xxx@xxx-mac ~ % node -i --eval="console.log('hello')"
Welcome to Node.js v14.17.6.
Type ".help" for more information.
> hello

> 
> 
(To exit, press Ctrl+C again or Ctrl+D or type .exit)
> 

If that is the case, please double check you cannot access that feature, and share the graalvm version and OS you are using. Otherwise, please elaborate more of what are you expecting.

rodrigar-mx avatar Jan 12 '22 23:01 rodrigar-mx

Hi @Melab. Do you mean like this?

xxx@xxx-mac ~ % java -version
openjdk version "11.0.13" 2021-10-19
OpenJDK Runtime Environment GraalVM CE 21.3.0 (build 11.0.13+7-jvmci-21.3-b05)
OpenJDK 64-Bit Server VM GraalVM CE 21.3.0 (build 11.0.13+7-jvmci-21.3-b05, mixed mode, sharing)
xxx@xxx-mac ~ % node -v
v14.17.6
xxx@xxx-mac ~ % node -i --eval="console.log('hello')"
Welcome to Node.js v14.17.6.
Type ".help" for more information.
> hello

> 
> 
(To exit, press Ctrl+C again or Ctrl+D or type .exit)
> 

If that is the case, please double check you cannot access that feature, and share the graalvm version and OS you are using. Otherwise, please elaborate more of what are you expecting.

Yes, @rodrigar-mx, like that. I am not using Graal-Node.

Melab avatar Jan 18 '22 23:01 Melab

Hi,

I assume you mean we should add the --i flag to the graalvm/bin/js binary and allow to use --eval and the interactive REPL in collaboration?

That sounds like a reasonable addition to the codebase. However, improvements to the js REPL are pretty low on our priorities list - if you need that feature, you can always just use the node binary, right?

-- Christian

wirthi avatar Jan 18 '22 23:01 wirthi

Hi,

I assume you mean we should add the --i flag to the graalvm/bin/js binary and allow to use --eval and the interactive REPL in collaboration?

That sounds like a reasonable addition to the codebase. However, improvements to the js REPL are pretty low on our priorities list - if you need that feature, you can always just use the node binary, right?

-- Christian

Yes. A way to execute script code before launching the REPL. Node offers command line options for:

  • preloading modules (in the case of GraalVM JavaScript, it should be expanded to non-module files) before running a file or launching the REPL.
  • evaluating code passed a command line parameter prior to launching the REPL (ideally, GraalVM JavaScript would also allow this to be done before running a file, not just the REPL).

Melab avatar Jan 21 '22 13:01 Melab