Skip to content

Instantly share code, notes, and snippets.

@willnode
Last active March 11, 2024 04:53
Show Gist options
  • Save willnode/2f0a3160a97950e10da142871f65c2b3 to your computer and use it in GitHub Desktop.
Save willnode/2f0a3160a97950e10da142871f65c2b3 to your computer and use it in GitHub Desktop.
install medusa.js without interactive prompts
#!/usr/bin/expect -f
# Check if the correct number of arguments is provided
if { $argc != 2 } {
puts "Usage: $argv0 <npx_command_arguments> <admin_email>"
exit 1
}
# Set timeout for expect
set timeout -1
# Extract the npx command arguments and admin email from command line arguments
set npx_args [lindex $argv 0]
set admin_email [lindex $argv 1]
# Extract the npx command arguments and admin email from command line arguments
set npx_args [lindex $argv 0]
set admin_email [lindex $argv 1]
# Split the npx command arguments into a list
set npx_args_list [split $npx_args " "]
# Spawn the command with the hardcoded npx command and provided arguments
spawn npx create-medusa-app@latest {*}$npx_args_list
# Expect the first question and provide the project name
expect "? What's the name of your project?"
send -- "my-medusa-store\r"
# Expect the second question and provide the admin email
expect "? Enter an email for your admin dashboard user"
send -- "$admin_email\r"
# Wait for the command to finish
expect eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment