Skip to content

Commit

Permalink
assets: report an error in ob run when referenced file doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-abrar committed May 24, 2022
1 parent 59cfd6a commit 3a33bda
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ This project's release branch is `master`. This log is written from the perspect
* [#903](https://github.com/obsidiansystems/obelisk/pull/903): Added support for a file which allows users to specify global variables and namespaces in JS, that should not be used by the Google Closure Compiler during minification of the GHCJS produced JS. See the [FAQ](FAQ.md).
* Static Assets
* [#922](https://github.com/obsidiansystems/obelisk/pull/922): Serve .wasm files with the correct MIME type
* Add a warning to ob run when `static` is called with a path to a file that doesn't exist

## v1.0.0.0 - 2022-01-04

Expand Down
8 changes: 7 additions & 1 deletion lib/asset/manifest/src/Obelisk/Asset/TH.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ module Obelisk.Asset.TH

import Obelisk.Asset.Gather

import Control.Monad
import Language.Haskell.TH
import Language.Haskell.TH.Syntax
import System.Directory
import System.FilePath.Posix

-- | Produces the hashed path of a file
Expand All @@ -31,7 +33,11 @@ staticPrefix :: FilePath
staticPrefix = "/static"

staticAssetRaw :: FilePath -> Q Exp
staticAssetRaw fp = returnQ $ LitE $ StringL $ staticPrefix </> fp
staticAssetRaw fp = do
exists <- runIO $ doesFileExist $ "static.out/" <> fp
when (not exists) $
fail $ "The file " <> fp <> " was not found in static.out"
returnQ $ LitE $ StringL $ staticPrefix </> fp

staticAssetHashed :: FilePath -> FilePath -> Q Exp
staticAssetHashed root fp = do
Expand Down

0 comments on commit 3a33bda

Please # to comment.