2020-09-07 22:55:13 +03:00
|
|
|
module Command.Clean
|
2021-04-28 18:36:00 +03:00
|
|
|
( clean,
|
|
|
|
)
|
|
|
|
where
|
2020-09-07 22:55:13 +03:00
|
|
|
|
2021-04-28 18:36:00 +03:00
|
|
|
import qualified Cli.Common as Common
|
|
|
|
import Command (Command)
|
|
|
|
import Command.Common (findWaspProjectRootDirFromCwd)
|
|
|
|
import Control.Monad.IO.Class (liftIO)
|
|
|
|
import qualified StrongPath as SP
|
|
|
|
import System.Directory
|
|
|
|
( doesDirectoryExist,
|
|
|
|
removeDirectoryRecursive,
|
|
|
|
)
|
|
|
|
import System.IO (hFlush, stdout)
|
2020-09-07 22:55:13 +03:00
|
|
|
|
|
|
|
clean :: Command ()
|
|
|
|
clean = do
|
2021-04-28 18:36:00 +03:00
|
|
|
waspProjectDir <- findWaspProjectRootDirFromCwd
|
|
|
|
let dotWaspDirFp = SP.toFilePath $ waspProjectDir SP.</> Common.dotWaspDirInWaspProjectDir
|
|
|
|
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."
|