No Forced Paths

This commit is contained in:
2026-04-21 15:41:01 +02:00
parent f249108cf0
commit 64f357734c
+23 -10
View File
@@ -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 {