diff --git a/src/Roux/Server.hs b/src/Roux/Server.hs index c2199c3..6c667d0 100644 --- a/src/Roux/Server.hs +++ b/src/Roux/Server.hs @@ -39,7 +39,7 @@ import System.FSNotify ( watchDir, withManagerConf, ) -import System.FilePath (makeRelative, ()) +import System.FilePath (makeRelative, takeBaseName, ()) import qualified Data.Aeson as A import qualified Data.ByteString as BS @@ -324,7 +324,13 @@ runImportPipeline recipeDir url = do let cookText = CooklangPrint.renderRecipe recipe filename = CooklangPrint.filenameFromTitle (soName schema) filepath = recipeDir filename - -- Step 4: write the .cook file + -- Save raw JSON alongside the .cook for debugging + jsonFilename = takeBaseName filename <> ".json" + jsonFilepath = recipeDir jsonFilename + -- Step 4: write raw JSON from scraper + putStrLn $ "[roux] writing raw scraper JSON to " <> jsonFilepath + LB.writeFile jsonFilepath stdoutBytes + -- Step 5: write the .cook file putStrLn $ "[roux] writing imported recipe to " <> filepath BS.writeFile filepath (TE.encodeUtf8 cookText) putStrLn $ "[roux] successfully imported " <> T.unpack url <> " as " <> filename