@@ -310,8 +310,14 @@ function rubySourceFromURL(): RubySource | null {
310310 return { type : "builtin" , version : "3.4" }
311311}
312312
313- type Options = {
313+ export type Options = {
314314 arguments : string [ ] ,
315+ env : Record < string , string > ,
316+ }
317+
318+ const DEFAULT_OPTIONS : Options = {
319+ arguments : [ ] ,
320+ env : { } ,
315321}
316322
317323type UIState = {
@@ -483,9 +489,7 @@ puts RUBY_DESCRIPTION`
483489
484490 let options = JSON . parse ( query . get ( "options" ) ) as Options | null
485491 if ( options == null ) {
486- options = {
487- arguments : [ ] ,
488- }
492+ options = DEFAULT_OPTIONS
489493 }
490494
491495 return { code, action, options }
@@ -660,12 +664,12 @@ export async function init(config: PlayRubyConfig) {
660664 const runCode = async ( code : string ) => {
661665 const selectedAction = actionSelect . value
662666 outputPane . innerText = ""
663- let args : string [ ] = [ ]
667+ let options : Options = DEFAULT_OPTIONS
664668 const outputWriter = ( selectedAction == "compile" || selectedAction == "syntax" || selectedAction == "syntax+prism" )
665669 ? new LocationHighlightingOutputWriter ( outputPane , editor )
666670 : new PlainOutputWriter ( outputPane )
667671 try {
668- args = getOptions ( ) . arguments
672+ options = getOptions ( )
669673 } catch ( error ) {
670674 outputWriter . write ( `Error parsing options: ${ error . message } \n` )
671675 return ;
@@ -677,7 +681,7 @@ export async function init(config: PlayRubyConfig) {
677681 // Prepend empty lines to the file content to match the original source line
678682 codeMap [ filename ] = "\n" . repeat ( file . sourceLine + 1 ) + file . content
679683 }
680- await worker . run ( codeMap , mainFile , selectedAction , args , Comlink . proxy ( ( text ) => outputWriter . write ( text ) ) )
684+ await worker . run ( codeMap , mainFile , selectedAction , options , Comlink . proxy ( ( text ) => outputWriter . write ( text ) ) )
681685 outputWriter . finalize ( )
682686 }
683687 const run = async ( ) => await runCode ( getCode ( ) ) ;
0 commit comments