Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@ package cmd
import (
"context"
"fmt"
"log"
"os"
"os/exec"

"github.com/railwayapp/cli/entity"
"github.com/railwayapp/cli/errors"
)

func (h *Handler) Run(ctx context.Context, req *entity.CommandRequest) error {
envs, err := h.ctrl.GetEnvs(ctx)

if err != nil {
log.Fatal(err)
return err
}

if len(req.Args) == 0 {
return errors.CommandNotSpecified
}

cmd := exec.Command(req.Args[0], req.Args[1:]...)
Expand All @@ -31,7 +35,7 @@ func (h *Handler) Run(ctx context.Context, req *entity.CommandRequest) error {

err = cmd.Run()
if err != nil {
fmt.Println(err.Error())
return err
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion configs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func New() *Configs {
return &Configs{
projectConfigs: projectConfig,
userConfigs: userConfig,
RailwayProductionToken: os.Getenv("RAILWAY_PRODUCTION_TOKEN"),
RailwayProductionToken: os.Getenv("RAILWAY_TOKEN"),
RailwayEnvFilePath: path.Join(projectDir, "env.json"),
}
}
3 changes: 2 additions & 1 deletion errors/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ var (
ProjectConfigNotFound RailwayError = errors.New("Not connected to a project. Run railway init to get started.")
ProjectNotFound RailwayError = errors.New("Project not found.")
ProjectCreateFailed RailwayError = errors.New("There was a problem creating the project")
ProductionTokenNotSet RailwayError = errors.New("RAILWAY_PRODUCTION_TOKEN environment variable not set")
ProductionTokenNotSet RailwayError = errors.New("RAILWAY_TOKEN environment variable not set")
CommandNotSpecified RailwayError = errors.New("Specify a command to run in side the railway environment. railway run <cmd>")
)
5 changes: 0 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ func init() {
Short: "Run command inside the Railway environment",
RunE: contextualize(handler.Run),
})
rootCmd.AddCommand(&cobra.Command{
Use: "build",
Short: "Generate env file for running Railway in production",
RunE: contextualize(handler.Build),
})
}

func main() {
Expand Down