@@ -16,11 +16,13 @@ Usage:
1616package main
1717
1818import (
19+ "errors"
1920 "fmt"
2021 "github.com/aws-robotics/aws-robomaker-bundle-support-library/pkg/stream/local"
2122 "io/ioutil"
2223 "log"
2324 "os"
25+ "path/filepath"
2426
2527 "github.com/aws-robotics/aws-robomaker-bundle-support-library/pkg/bundle"
2628 "github.com/aws-robotics/aws-robomaker-bundle-support-library/pkg/store"
@@ -45,9 +47,27 @@ func main() {
4547
4648 app .Action = func (c * cli.Context ) error {
4749 cachePath := c .String ("cache" )
50+ if _ , err := os .Stat (cachePath ); os .IsNotExist (err ) {
51+ err = os .Mkdir (cachePath , os .ModePerm )
52+ if err != nil {
53+ fmt .Printf ("Failed to create cache directory: %s" , cachePath )
54+ log .Fatal (err )
55+ return err
56+ }
57+ }
4858 bundleStore := store .NewSimpleStore (cachePath )
4959
5060 bundlePath := c .String ("bundle" )
61+ if bundlePath == "" {
62+ fmt .Println ("Bundle path cannot be empty." )
63+ return errors .New ("bundle path cannot be empty" )
64+ }
65+ absBundlePath , err := filepath .Abs (bundlePath )
66+ if err != nil {
67+ fmt .Printf ("Bundle path is invalid: %s" , bundlePath )
68+ log .Fatal (err )
69+ return err
70+ }
5171 prefixPath := c .String ("prefix" )
5272
5373 files , err := ioutil .ReadDir (cachePath )
@@ -69,13 +89,13 @@ func main() {
6989 }
7090
7191 bundleProvider := bundle .NewProvider (bundleStore )
72- b , err := bundleProvider .GetBundle (bundlePath )
92+ b , err := bundleProvider .GetBundle (absBundlePath )
7393 if err != nil {
7494 log .Fatal (err )
7595 return err
7696 }
7797 for i := 0 ; i < len (b .PosixSourceCommands ()); i ++ {
78- fmt .Print (b .PosixSourceCommandsUsingLocation (prefixPath )[i ])
98+ fmt .Println (b .PosixSourceCommandsUsingLocation (prefixPath )[i ])
7999 }
80100
81101 return nil
0 commit comments