From a226f9c29444a3af92f3a31f53db167c9ba622ae Mon Sep 17 00:00:00 2001 From: Nicolas Mattia Date: Sun, 8 Dec 2019 20:41:22 +0100 Subject: [PATCH] Cleanup Niv.Cli --- src/Niv/Cli.hs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Niv/Cli.hs b/src/Niv/Cli.hs index 831e5ac..953a608 100644 --- a/src/Niv/Cli.hs +++ b/src/Niv/Cli.hs @@ -1,5 +1,4 @@ {-# LANGUAGE DerivingStrategies #-} -{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} @@ -120,7 +119,7 @@ cmdInit = do if shouldUpdateNixSourcesNix content then do say "Updating sources.nix" - liftIO $ B.writeFile path initNixSourcesNixContent + li $ B.writeFile path initNixSourcesNixContent else say "Not updating sources.nix" ) , ( pathNixSourcesJson fsj @@ -144,8 +143,8 @@ cmdInit = do ) , \path _content -> dontCreateFile path) ] $ \(path, onCreate, onUpdate) -> do - exists <- liftIO $ Dir.doesFileExist path - if exists then liftIO (B.readFile path) >>= onUpdate path else onCreate path + exists <- li $ Dir.doesFileExist path + if exists then li (B.readFile path) >>= onUpdate path else onCreate path case fsj of Auto -> pure () AtPath fp -> @@ -164,7 +163,7 @@ cmdInit = do where createFile :: FilePath -> B.ByteString -> NIO () - createFile path content = liftIO $ do + createFile path content = li $ do let dir = takeDirectory path Dir.createDirectoryIfMissing True dir say $ "Creating " <> path @@ -251,7 +250,7 @@ cmdAdd :: Update () a -> PackageName -> Attrs -> NIO () cmdAdd updateFunc packageName attrs = do job ("Adding package " <> T.unpack (unPackageName packageName)) $ do fsj <- getFindSourcesJson - sources <- unSources <$> liftIO (getSources fsj) + sources <- unSources <$> li (getSources fsj) when (HMS.member packageName sources) $ li $ abortCannotAddPackageExists packageName