2020-09-07 22:55:13 +03:00
|
|
|
module Command.Clean
|
|
|
|
( clean
|
|
|
|
) where
|
|
|
|
|
|
|
|
import System.Directory (doesDirectoryExist, removeDirectoryRecursive)
|
|
|
|
import System.IO (hFlush, stdout)
|
|
|
|
import Control.Monad.IO.Class (liftIO)
|
|
|
|
|
|
|
|
import qualified StrongPath as SP
|
|
|
|
import Command (Command)
|
2020-09-11 18:31:17 +03:00
|
|
|
import Command.Common (findWaspProjectRootDirFromCwd)
|
2020-09-07 22:55:13 +03:00
|
|
|
import qualified Common
|
|
|
|
|
|
|
|
clean :: Command ()
|
|
|
|
clean = do
|
2020-09-11 18:31:17 +03:00
|
|
|
waspProjectDir <- findWaspProjectRootDirFromCwd
|
|
|
|
let dotWaspDirFp = SP.toFilePath $ waspProjectDir SP.</> Common.dotWaspDirInWaspProjectDir
|
2020-09-07 22:55:13 +03:00
|
|
|
liftIO $ putStrLn "Deleting .wasp/ directory..." >> hFlush stdout
|
|
|
|
doesDotWaspDirExist <- liftIO $ doesDirectoryExist dotWaspDirFp
|
|
|
|
if doesDotWaspDirExist
|
|
|
|
then liftIO $ do removeDirectoryRecursive dotWaspDirFp
|
|
|
|
putStrLn "Deleted .wasp/ directory."
|
|
|
|
else liftIO $ putStrLn "Nothing to delete: .wasp directory does not exist."
|
|
|
|
|