From 29952d456cf354b06a70595fb65df2a7974321d6 Mon Sep 17 00:00:00 2001 From: James Brechtel Date: Wed, 20 May 2026 14:25:37 -0400 Subject: [PATCH] fix: resolve scrape-recipe script path via PATH then fallback to scripts/ --- src/Roux/Server.hs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Roux/Server.hs b/src/Roux/Server.hs index 369c7fd..259bddd 100644 --- a/src/Roux/Server.hs +++ b/src/Roux/Server.hs @@ -29,7 +29,7 @@ import Data.Time.Clock (diffUTCTime, getCurrentTime) import qualified Network.HTTP.Types as HTTP import qualified Network.Wai as Wai -import System.Directory (doesFileExist, makeAbsolute) +import System.Directory (doesFileExist, findExecutable, makeAbsolute) import System.FSNotify ( Event (..), EventIsDirectory (..), @@ -227,13 +227,24 @@ parseFormBody body = _ -> Nothing urldecode = T.pack . Html.urlDecode . T.replace "+" " " +-- | Locate the scrape-recipe script: check PATH first, then relative to project. +findScrapeScript :: IO FilePath +findScrapeScript = do + -- In production Docker, the script is at /usr/local/bin/scrape-recipe (on PATH). + -- In development from the project root, it is at scripts/scrape-recipe. + mPath <- findExecutable "scrape-recipe" + case mPath of + Just p -> pure p + Nothing -> pure "scripts/scrape-recipe" + -- | Run the full import pipeline: scrape -> parse -> convert -> render -> save. runImportPipeline :: FilePath -> Text -> IO (Either Html.ImportError FilePath) runImportPipeline recipeDir url = do -- Step 1: scrape the URL + script <- findScrapeScript (exitCode, stdout, stderr) <- readProcessWithExitCode - "scripts/scrape-recipe" + script ["--pretty", T.unpack url] "" case exitCode of