No Forced Paths
This commit is contained in:
+23
-10
@@ -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,12 +168,21 @@ 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
|
||||||
ext := strings.ToLower(filepath.Ext(path))
|
var sourceExts []string
|
||||||
return ext == ".json" || ext == ".nss"
|
|
||||||
})
|
sourceDir := p.SourceDir()
|
||||||
if err != nil {
|
if sourceDir != "" && filepath.Clean(sourceDir) != p.Root {
|
||||||
return fmt.Errorf("scan source tree: %w", err)
|
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 {
|
assetFiles, _, err := scanDir(p.AssetsDir(), func(path string) bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user