No Forced Paths

This commit is contained in:
2026-04-21 15:41:01 +02:00
parent f249108cf0
commit 64f357734c
+18 -5
View File
@@ -138,11 +138,15 @@ func (p *Project) ValidateLayout() error {
} }
} }
for label, path := range map[string]string{ for label, pathFn := range map[string]func() string{
"paths.source": p.SourceDir(), "paths.source": p.SourceDir,
"paths.assets": p.AssetsDir(), "paths.assets": p.AssetsDir,
"paths.build": p.BuildDir(), "paths.build": p.BuildDir,
} { } {
path := pathFn()
if path == "" || filepath.Clean(path) == p.Root {
continue
}
info, err := os.Stat(path) info, err := os.Stat(path)
if err != nil { if err != nil {
if label == "paths.assets" && errors.Is(err, os.ErrNotExist) { if label == "paths.assets" && errors.Is(err, os.ErrNotExist) {
@@ -164,13 +168,22 @@ func (p *Project) ValidateLayout() error {
} }
func (p *Project) Scan() error { func (p *Project) Scan() error {
sourceFiles, sourceExts, err := scanDir(p.SourceDir(), func(path string) bool { 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)) ext := strings.ToLower(filepath.Ext(path))
return ext == ".json" || ext == ".nss" return ext == ".json" || ext == ".nss"
}) })
if err != nil { if err != nil {
if !errors.Is(err, os.ErrNotExist) {
return fmt.Errorf("scan source tree: %w", err) return fmt.Errorf("scan source tree: %w", err)
} }
}
}
assetFiles, _, err := scanDir(p.AssetsDir(), func(path string) bool { assetFiles, _, err := scanDir(p.AssetsDir(), func(path string) bool {
ext := strings.ToLower(filepath.Ext(path)) ext := strings.ToLower(filepath.Ext(path))