Class: Daytona::SandboxJsCodeToolbox

Inherits:
Object
  • Object
show all
Defined in:
lib/daytona/code_toolbox/sandbox_js_code_toolbox.rb

Instance Method Summary collapse

Instance Method Details

#get_run_command(code, params = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/daytona/code_toolbox/sandbox_js_code_toolbox.rb', line 7

def get_run_command(code, params = nil)
  # Encode the provided code in base64
  base64_code = Base64.strict_encode64(code)

  # Build command-line arguments string
  argv = ''
  argv = params.argv.join(' ') if params&.argv && !params.argv.empty?

  # Combine everything into the final command for JavaScript
  " sh -c 'echo #{base64_code} | base64 --decode | node -e \"$(cat)\" #{argv} 2>&1 | grep -vE \"npm notice\"' "
end