From 0f44431086de18498369ac6993d5576b49a9dd50 Mon Sep 17 00:00:00 2001 From: Pagwin Date: Sun, 28 Dec 2025 20:38:04 -0500 Subject: [PATCH] changed main code to handle refactored js parsing API --- src/Psb/Main.hs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Psb/Main.hs b/src/Psb/Main.hs index b62f719..2ae2e21 100644 --- a/src/Psb/Main.hs +++ b/src/Psb/Main.hs @@ -21,6 +21,7 @@ import qualified Development.Shake as Shake import Development.Shake.FilePath (()) import qualified Development.Shake.FilePath as FP import Templates +import Text.Megaparsec (errorBundlePretty) import Types import Utilities.Action (getPublishedPosts, isDraft', markdownToHtml, markdownToPost, now, psbProgress) import qualified Utilities.CSS as CSS @@ -92,9 +93,15 @@ css_resources = js_resources :: Rules () js_resources = map (outputDir ) jsGlobs |%> \target -> do - src <- Shake.readFile' $ FP.dropDirectory1 target - -- TODO: write to fingerprinted location as well - Shake.writeFileChanged target $ JS.minify src + let src_file = FP.dropDirectory1 target + src <- Shake.readFile' $ src_file + + let tokenization = JS.toTokens src_file src + case tokenization of + Left e -> error $ "Attempt to tokenize javascript file failed with: " <> errorBundlePretty e + Right tokens -> + -- TODO: write to fingerprinted location as well + Shake.writeFileChanged target $ foldMap JS.displayToken $ JS.minify $ tokens -- there's probably a better way of doing this that allows for the target's origin file extension to get passed in but for now we're doing brute force postsRule :: Rules ()