Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

assets: add an error to ob run when file doesn't exist #930

Merged
merged 4 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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