Skip to content

Commit

Permalink
fix(cli): trim tailing / when neva run or neva build are executed
Browse files Browse the repository at this point in the history
  • Loading branch information
emil14 committed Dec 10, 2024
1 parent ffb7907 commit dcc469d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion internal/cli/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func newBuildCmd(
},
ArgsUsage: "Provide path to main package",
Action: func(cliCtx *cli.Context) error {
mainPkg, err := getMainPkgFromArgs(cliCtx)
mainPkg, err := mainPkgPathFromArgs(cliCtx)
if err != nil {
return err
}
Expand Down
14 changes: 9 additions & 5 deletions internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,17 @@ func newGetCmd(workdir string, bldr builder.Builder) *cli.Command {
}
}

func getMainPkgFromArgs(cCtx *cli.Context) (string, error) {
firstArg := cCtx.Args().First()
dirFromArg := strings.TrimSuffix(firstArg, "/main.neva")
if filepath.Ext(dirFromArg) != "" {
func mainPkgPathFromArgs(cCtx *cli.Context) (string, error) {
arg := cCtx.Args().First()

path := strings.TrimSuffix(arg, "main.neva")
path = strings.TrimSuffix(path, "/")

if filepath.Ext(path) != "" {
return "", errors.New(
"Use path to directory with executable package, relative to module root",
)
}
return dirFromArg, nil

return path, nil
}
2 changes: 1 addition & 1 deletion internal/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func newRunCmd(workdir string, nativec compiler.Compiler) *cli.Command {
},
ArgsUsage: "Provide path to main package",
Action: func(cliCtx *cli.Context) error {
mainPkg, err := getMainPkgFromArgs(cliCtx)
mainPkg, err := mainPkgPathFromArgs(cliCtx)
if err != nil {
return err
}
Expand Down

0 comments on commit dcc469d

Please sign in to comment.