Skip to content

Commit

Permalink
Use data-files to load confer.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
tchoutri committed Jun 28, 2024
1 parent 68888f7 commit 9965a51
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
10 changes: 9 additions & 1 deletion app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ module Main where

import Data.Function ((&))
import Data.Map.Strict qualified as Map
import Data.Version (showVersion)
import Effectful
import Effectful.Error.Static
import Effectful.FileSystem
import Options.Applicative
import Options.Applicative.Types
import Paths_confer (version)
import System.IO
import System.OsPath
import System.OsPath qualified as OsPath
Expand Down Expand Up @@ -90,7 +92,13 @@ runOptions (Options dryRun configurationFile Deploy) = do
& runSymlinkIO

withInfo :: Parser a -> String -> ParserInfo a
withInfo opts desc = info (helper <*> opts) $ progDesc desc
withInfo opts desc =
info
( simpleVersioner (showVersion version)
<*> helper
<*> opts
)
$ progDesc desc

osPathOption :: ReadM OsPath
osPathOption = maybeReader OsPath.encodeUtf
17 changes: 10 additions & 7 deletions confer.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extra-doc-files:
doc/*.md
README.md

data-dir: runtime/lua
data-files: runtime/lua/confer.lua
tested-with: GHC ==9.8.2

flag development
Expand Down Expand Up @@ -71,6 +71,8 @@ library
Confer.Config.Types
Confer.Effect.Symlink

other-modules: Paths_confer
autogen-modules: Paths_confer
build-depends:
, aeson
, base
Expand Down Expand Up @@ -98,10 +100,13 @@ library
hs-source-dirs: src

executable confer
import: extensions
import: ghc-options
import: rts-options
main-is: Main.hs
import: extensions
import: ghc-options
import: rts-options
hs-source-dirs: app
main-is: Main.hs
other-modules: Paths_confer
autogen-modules: Paths_confer
build-depends:
, base
, confer
Expand All @@ -114,8 +119,6 @@ executable confer
if flag(development)
build-depends: placeholder

hs-source-dirs: app

test-suite confer-test
import: extensions
import: ghc-options
Expand Down
12 changes: 7 additions & 5 deletions src/Confer/Config/Evaluator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Confer.Config.Evaluator

import Control.Monad (void)

Check warning on line 6 in src/Confer/Config/Evaluator.hs

View workflow job for this annotation

GitHub Actions / 9.8.2 on macos-latest

The import of ‘Control.Monad’ is redundant

Check warning on line 6 in src/Confer/Config/Evaluator.hs

View workflow job for this annotation

GitHub Actions / 9.8.2 on ubuntu-latest

The import of ‘Control.Monad’ is redundant

Check warning on line 6 in src/Confer/Config/Evaluator.hs

View workflow job for this annotation

GitHub Actions / Build statically linked using alpine

The import of ‘Control.Monad’ is redundant
import Control.Placeholder
import Data.Maybe (isNothing)
import Data.Text (Text)
import Data.Text qualified as Text
import Data.Text.IO qualified as Text
Expand All @@ -19,7 +20,10 @@ import HsLua.Marshalling (Peeker, Result)
import HsLua.Marshalling qualified as Lua
import HsLua.Module.System qualified as Lua.System
import HsLua.Packaging.Module qualified as Lua
import Paths_confer (getDataFileName)
import System.Directory qualified as Directory
import System.IO (utf16le, utf8)
import System.IO.Unsafe qualified as Unsafe
import System.Info qualified as System
import System.OsPath (OsPath)
import System.OsPath qualified as OsPath
Expand All @@ -28,9 +32,6 @@ import System.OsPath.Encoding qualified as OsPath
import Confer.API.Host qualified as API
import Confer.API.User qualified as API
import Confer.Config.Types
import Data.Maybe (isNothing)
import System.Directory qualified as Directory
import System.IO.Unsafe qualified as Unsafe

adjustConfiguration
:: Text
Expand Down Expand Up @@ -58,8 +59,9 @@ loadConfiguration pathToConfigFile = do
hostModule <- API.mkHostModule
liftIO $ Lua.run $ do
Lua.openlibs -- load the default Lua packages
liftIO $ Text.putStrLn "Loading \"./runtime/lua/confer.lua\""
Lua.dofile (Just "./runtime/lua/confer.lua")
conferLuaFilePath <- liftIO $ getDataFileName "runtime/lua/confer.lua"
liftIO $ Text.putStrLn $ "Loading " <> Text.pack conferLuaFilePath
Lua.dofile (Just conferLuaFilePath)
Lua.setglobal "confer"
Lua.registerModule Lua.System.documentedModule
Lua.registerModule userModule
Expand Down

0 comments on commit 9965a51

Please sign in to comment.