diff --git a/internal/project/project.go b/internal/project/project.go index 7a3124f..e68c34d 100644 --- a/internal/project/project.go +++ b/internal/project/project.go @@ -138,11 +138,15 @@ func (p *Project) ValidateLayout() error { } } - for label, path := range map[string]string{ - "paths.source": p.SourceDir(), - "paths.assets": p.AssetsDir(), - "paths.build": p.BuildDir(), + for label, pathFn := range map[string]func() string{ + "paths.source": p.SourceDir, + "paths.assets": p.AssetsDir, + "paths.build": p.BuildDir, } { + path := pathFn() + if path == "" || filepath.Clean(path) == p.Root { + continue + } info, err := os.Stat(path) if err != nil { if label == "paths.assets" && errors.Is(err, os.ErrNotExist) { @@ -164,12 +168,21 @@ func (p *Project) ValidateLayout() error { } func (p *Project) Scan() error { - sourceFiles, sourceExts, err := scanDir(p.SourceDir(), func(path string) bool { - ext := strings.ToLower(filepath.Ext(path)) - return ext == ".json" || ext == ".nss" - }) - if err != nil { - return fmt.Errorf("scan source tree: %w", err) + var sourceFiles []string + var sourceExts []string + + sourceDir := p.SourceDir() + if sourceDir != "" && filepath.Clean(sourceDir) != p.Root { + var err error + sourceFiles, sourceExts, err = scanDir(sourceDir, func(path string) bool { + ext := strings.ToLower(filepath.Ext(path)) + return ext == ".json" || ext == ".nss" + }) + if err != nil { + if !errors.Is(err, os.ErrNotExist) { + return fmt.Errorf("scan source tree: %w", err) + } + } } assetFiles, _, err := scanDir(p.AssetsDir(), func(path string) bool {