Skip to content

Commit a21b03d

Browse files
committed
Refine relative loading of package overrides
1 parent 4de7845 commit a21b03d

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

builder/src/Http.hs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import qualified Elm.Version as V
4545

4646

4747
import Lamdera
48+
import qualified Lamdera.Relative
4849
import qualified Data.Text as T
4950

5051
-- MANAGER
@@ -321,7 +322,7 @@ lamderaGetArchive manager url onError err onSuccess =
321322
& (\x ->
322323
case x of
323324
package:version:_ ->
324-
(T.unpack package, T.unpack version)
325+
(T.unpack package, T.unpack version |> T.replace "/" "")
325326
_ ->
326327
error $ "unexpected URL parts: " <> show x
327328
)
@@ -331,15 +332,15 @@ lamderaGetArchive manager url onError err onSuccess =
331332
packageRoot = concat [pkgsPath & withDefault "<no-packages-path-override-set>", "/packages/", package, "/", version]
332333

333334
zipPath <- do
334-
exists <- doesFileExist packageZip
335-
if exists
336-
then pure packageZip
337-
else do
335+
overrideZipM <- Lamdera.Relative.findFile packageZip
336+
case overrideZipM of
337+
Just overrideZip -> pure overrideZip
338+
Nothing -> do
338339
-- Backwards compatible support for when pack.zip was used without a version number
339-
bareExists <- doesFileExist packageZipBare
340-
if bareExists
341-
then pure packageZipBare
342-
else pure ""
340+
zipBareM <- Lamdera.Relative.findFile packageZipBare
341+
case zipBareM of
342+
Just zipBare -> pure zipBare
343+
Nothing -> pure ""
343344

344345
-- debug_ $ "🔥: " <> show (package, packageZip, packageRoot, overrideExists, url)
345346

extra/Lamdera/Extensions.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import qualified Data.Text.Encoding as TE
1111

1212
import Lamdera
1313
import Lamdera.Project
14+
import qualified Lamdera.Relative
1415

1516

1617
-- The idea is to keep extension code in here, but so far the extensions have
@@ -40,7 +41,8 @@ elmJsonOverride pkg@(Pkg.Name author project) vsn original =
4041
packageRoot = (pkgsPath & withDefault "<no-packages-path-override-set>") <> "/packages/" <> Pkg.toUrl pkg ++ "/" ++ V.toChars vsn
4142
elmJson = packageRoot <> "/elm.json"
4243

43-
resM <- readUtf8Text elmJson
44+
debug $ "Looking for json override: " <> elmJson
45+
resM <- Lamdera.Relative.readFile elmJson
4446
case resM of
4547
Just res -> do
4648
debug $ "🔁 Serving local elm.json: " <> elmJson
@@ -66,7 +68,8 @@ endpointJsonOverride pkg@(Pkg.Name author project) vsn original =
6668
packageRoot = (pkgsPath & withDefault "<no-packages-path-override-set>") <> "/packages/" <> Pkg.toUrl pkg ++ "/" ++ V.toChars vsn
6769
endpointJson = packageRoot <> "/endpoint.json"
6870

69-
resM <- readUtf8Text endpointJson
71+
debug $ "Looking for endpoint override: " <> endpointJson
72+
resM <- Lamdera.Relative.readFile endpointJson
7073
case resM of
7174
Just res -> do
7275
debug $ "🔁 Serving local endpoint.json: " <> endpointJson

0 commit comments

Comments
 (0)