lang: gapi: Convenience the user by allowing relative dirs in cli
This commit is contained in:
@@ -34,6 +34,8 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -117,8 +119,15 @@ func (obj *GAPI) Cli(info *gapi.Info) (*gapi.Deploy, error) {
|
|||||||
|
|
||||||
// empty by default (don't set for deploy, only download)
|
// empty by default (don't set for deploy, only download)
|
||||||
modules := args.ModulePath
|
modules := args.ModulePath
|
||||||
if modules != "" && (!strings.HasPrefix(modules, "/") || !strings.HasSuffix(modules, "/")) {
|
if modules != "" && !strings.HasSuffix(modules, "/") {
|
||||||
return nil, fmt.Errorf("module path is not an absolute directory")
|
return nil, fmt.Errorf("module path does not end with a slash")
|
||||||
|
}
|
||||||
|
if modules != "" && !strings.HasPrefix(modules, "/") {
|
||||||
|
wd, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
modules = filepath.Join(wd, modules) + "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: while reading through trees of metadata files, we could also
|
// TODO: while reading through trees of metadata files, we could also
|
||||||
|
|||||||
Reference in New Issue
Block a user