Skip to content

Commit

Permalink
Add generic support for Ruby apps
Browse files Browse the repository at this point in the history
  • Loading branch information
sibprogrammer committed Jun 15, 2021
1 parent 925d6e9 commit 5f4ae45
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/actions/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ type Stack string
const (
StackPHP Stack = "PHP"
StackJS Stack = "JavaScript"
StackRuby Stack = "Ruby"
StackStatic Stack = "static"
StackUnknown Stack = "unknown"
)

func DetectStack() Stack {
if fileExists("Gemfile") && fileExists("config.ru") {
return StackRuby
}

if fileExists("composer.json") {
return StackPHP
}
Expand All @@ -40,6 +45,8 @@ func RunServer(stack Stack) error {
port := defaultPort

switch stack {
case StackRuby:
return runRuby(port)
case StackPHP:
return runPHP(port)
case StackJS:
Expand Down Expand Up @@ -84,6 +91,10 @@ func runJS() error {
return runCommand("npm", "start")
}

func runRuby(port string) error {
return runCommand("bundle", "exec", "rackup", "--port", port)
}

func runStatic(port string) error {
fmt.Println("Static server started:", "http://127.0.0.1:"+port)
return http.ListenAndServe(":"+port, http.FileServer(http.Dir(".")))
Expand Down

0 comments on commit 5f4ae45

Please sign in to comment.