fix: resolve scrape-recipe script path via PATH then fallback to scripts/
Build and Deploy / build-and-deploy (push) Successful in 1m20s

This commit is contained in:
2026-05-20 14:25:37 -04:00
parent 81723622be
commit 29952d456c
+13 -2
View File
@@ -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