From c7c872291c2b053afc2c27f999f33b2cfb6c23f1 Mon Sep 17 00:00:00 2001 From: pacien Date: Mon, 3 Feb 2020 14:27:33 +0100 Subject: compiler: fix viewer output directory exclusion GitHub: closes #87 --- compiler/app/Main.hs | 1 + compiler/src/Compiler.hs | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'compiler') diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs index e26055f..1864dee 100644 --- a/compiler/app/Main.hs +++ b/compiler/app/Main.hs @@ -103,6 +103,7 @@ main = compileGallery (inputDir opts) (galleryOutputDir opts) + [outputDir opts] (rebuilAll opts) (cleanOutput opts) diff --git a/compiler/src/Compiler.hs b/compiler/src/Compiler.hs index d392f74..adc4a5f 100644 --- a/compiler/src/Compiler.hs +++ b/compiler/src/Compiler.hs @@ -70,10 +70,10 @@ writeJSON outputPath object = ensureParentDir JSON.encodeFile outputPath object -galleryDirFilter :: CompilerConfig -> FilePath -> FSNode -> Bool -galleryDirFilter config outputDir = +galleryDirFilter :: CompilerConfig -> [FilePath] -> FSNode -> Bool +galleryDirFilter config excludedCanonicalDirs = (not . isHidden) - &&& (not . isOutputGallery) + &&& (not . isExcludedDir) &&& (not . matchesFile (== galleryConf)) &&& ((matchesDir $ anyPattern $ includedDirectories config) ||| (matchesFile $ anyPattern $ includedFiles config)) @@ -95,20 +95,20 @@ galleryDirFilter config outputDir = anyPattern :: [String] -> FileName -> Bool anyPattern patterns filename = any (flip Glob.match filename) (map Glob.compile patterns) - isOutputGallery :: FSNode -> Bool - isOutputGallery Dir{canonicalPath} = canonicalPath == outputDir - isOutputGallery File{} = False + isExcludedDir :: FSNode -> Bool + isExcludedDir Dir{canonicalPath} = any (canonicalPath ==) excludedCanonicalDirs + isExcludedDir File{} = False -compileGallery :: FilePath -> FilePath -> Bool -> Bool -> IO () -compileGallery inputDirPath outputDirPath rebuildAll cleanOutput = +compileGallery :: FilePath -> FilePath -> [FilePath] -> Bool -> Bool -> IO () +compileGallery inputDirPath outputDirPath excludedDirs rebuildAll cleanOutput = do fullConfig <- readConfig inputGalleryConf let config = compiler fullConfig inputDir <- readDirectory inputDirPath - canonicalOutPath <- canonicalizePath outputDirPath - let sourceFilter = galleryDirFilter config canonicalOutPath + excludedCanonicalDirs <- mapM canonicalizePath excludedDirs + let sourceFilter = galleryDirFilter config excludedCanonicalDirs let sourceTree = filterDir sourceFilter inputDir inputTree <- readInputTree sourceTree -- cgit v1.2.3