summaryrefslogtreecommitdiff
path: root/src/wrapper.hs
diff options
context:
space:
mode:
authorJoey Hess2016-11-12 01:41:30 -0400
committerJoey Hess2016-11-12 01:41:30 -0400
commitbde6a58ef862ab01ee89a07d815fad4a51361b5b (patch)
treed2f43d557e0509d59acc57e92888baaa2f1de80f /src/wrapper.hs
parentb4adaf75a36d6d6425df820c46023a32e79bb6df (diff)
check that config.hs mentions "Propellor"
from eg, "import Propellor"
Diffstat (limited to 'src/wrapper.hs')
-rw-r--r--src/wrapper.hs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/wrapper.hs b/src/wrapper.hs
index 6b24a368..06051500 100644
--- a/src/wrapper.hs
+++ b/src/wrapper.hs
@@ -7,8 +7,8 @@
-- This bootstraps ~/.propellor/config.hs, builds it if
-- it's not already built, and runs it.
--
--- If ./config.hs exists, it instead builds and runs in the
--- current working directory.
+-- If ./config.hs exists and looks like a propellor config file,
+-- it instead builds and runs in the current working directory.
module Main where
@@ -24,7 +24,10 @@ import Utility.Process.NonConcurrent
import System.Environment (getArgs)
import System.Exit
import System.Posix
+import Data.List
import Control.Monad.IfElse
+import Control.Applicative
+import Prelude
main :: IO ()
main = withConcurrentOutput $ go =<< getArgs
@@ -66,8 +69,13 @@ configInCurrentWorkingDirectory = ifM (doesFileExist "config.hs")
then unsafe "the current directory is group writable"
else if checkMode otherWriteMode (fileMode s)
then unsafe "the current directory is world-writable"
- else return True
+ else ifM mentionspropellor
+ ( return True
+ , notusing "it does not seem to be a propellor config file"
+ )
, return False
)
where
- unsafe s = error $ "Not using ./config.hs because " ++ s ++ ". This seems unsafe."
+ unsafe s = notusing (s ++ ". This seems unsafe.")
+ notusing s = error $ "Not using ./config.hs because " ++ s
+ mentionspropellor = ("Propellor" `isInfixOf`) <$> readFile "config.hs"