From 5f4ae455acf9a145f9a0ab8a3d7ce3ca5c223c38 Mon Sep 17 00:00:00 2001 From: Alexei Yuzhakov Date: Tue, 15 Jun 2021 22:11:41 +0700 Subject: [PATCH] Add generic support for Ruby apps --- internal/actions/web.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/actions/web.go b/internal/actions/web.go index f654cb1..fc13b69 100644 --- a/internal/actions/web.go +++ b/internal/actions/web.go @@ -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 } @@ -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: @@ -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(".")))