create cache directory if it doesn't already exist

This commit is contained in:
sharifelgamal 2018-11-14 11:20:16 -08:00
parent f99e5f5c6d
commit a74dc78c65
No known key found for this signature in database
GPG Key ID: 63E3F6ED6963163C
1 changed files with 6 additions and 0 deletions

View File

@ -51,6 +51,12 @@ var RootCmd = &cobra.Command{
return nil
},
Run: func(cmd *cobra.Command, args []string) {
if _, err := os.Stat(opts.CacheDir); os.IsNotExist(err) {
err = os.MkdirAll(opts.CacheDir, 0755)
if err != nil {
exit(errors.Wrap(err, "Failed to create cache directory"))
}
}
if err := cache.WarmCache(opts); err != nil {
exit(errors.Wrap(err, "Failed warming cache"))
}