this repo has no description smallweb.run
smallweb
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix app dir detection

pomdtr 7227b875 d7641851

+25 -14
+6
cmd/crons.go
··· 6 6 "fmt" 7 7 "log/slog" 8 8 "os" 9 + "path" 9 10 "path/filepath" 10 11 "strings" 11 12 "time" ··· 53 54 return fmt.Errorf("failed to get current directory: %w", err) 54 55 } 55 56 57 + if cwd == path.Clean(k.String("dir")) { 58 + return fmt.Errorf("not in an app directory") 59 + } 60 + 56 61 if !strings.HasPrefix(cwd, k.String("dir")) { 57 62 return fmt.Errorf("not in an app directory") 58 63 } 64 + 59 65 appDir := cwd 60 66 for filepath.Dir(appDir) != k.String("dir") { 61 67 appDir = filepath.Dir(appDir)
+9 -13
cmd/open.go
··· 3 3 import ( 4 4 "fmt" 5 5 "os" 6 + "path" 6 7 "path/filepath" 7 8 "strings" 8 9 ··· 21 22 Short: "Open an app in the browser", 22 23 Args: cobra.NoArgs, 23 24 RunE: func(cmd *cobra.Command, args []string) error { 25 + appName := flags.app 24 26 if flags.app == "" { 25 27 cwd, err := os.Getwd() 26 28 if err != nil { 27 - return fmt.Errorf("failed to get current directory: %w", err) 29 + return fmt.Errorf("could not get current working directory: %v", err) 30 + } 31 + 32 + if cwd == path.Clean(k.String("dir")) { 33 + return fmt.Errorf("not in an app directory") 28 34 } 29 35 30 36 if !strings.HasPrefix(cwd, k.String("dir")) { ··· 36 42 appDir = filepath.Dir(appDir) 37 43 } 38 44 39 - appName := filepath.Base(appDir) 40 - a, err := app.LoadApp(appName, k.String("dir"), k.String("domain")) 41 - if err != nil { 42 - return fmt.Errorf("failed to load app: %w", err) 43 - } 44 - 45 - if err := browser.OpenURL(a.URL); err != nil { 46 - return fmt.Errorf("failed to open browser: %w", err) 47 - } 48 - 49 - return nil 45 + appName = filepath.Base(appDir) 50 46 } 51 47 52 - a, err := app.LoadApp(flags.app, k.String("dir"), k.String("domain")) 48 + a, err := app.LoadApp(appName, k.String("dir"), k.String("domain")) 53 49 if err != nil { 54 50 return fmt.Errorf("failed to load app: %w", err) 55 51 }
+10 -1
cmd/secrets.go
··· 5 5 "encoding/json" 6 6 "fmt" 7 7 "os" 8 + "path" 8 9 "path/filepath" 9 10 "strings" 10 11 ··· 37 38 if appName == "" { 38 39 cwd, err := os.Getwd() 39 40 if err != nil { 40 - return fmt.Errorf("failed to get current directory: %w", err) 41 + return fmt.Errorf("could not get current working directory: %v", err) 42 + } 43 + 44 + if cwd == path.Clean(k.String("dir")) { 45 + return fmt.Errorf("not in an app directory") 41 46 } 42 47 43 48 if !strings.HasPrefix(cwd, k.String("dir")) { ··· 56 61 57 62 rawBytes, err := os.ReadFile(secretPath) 58 63 if err != nil { 64 + if os.IsNotExist(err) { 65 + return fmt.Errorf("secrets file %s does not exist", secretPath) 66 + } 67 + 59 68 return fmt.Errorf("could not read %s: %v", secretPath, err) 60 69 } 61 70