packages feed

stack-clean-old 0.2.1 → 0.2.2

raw patch · 5 files changed

+27/−5 lines, 5 filesdep ~base

Dependency ranges changed: base

Files

ChangeLog.md view
@@ -1,6 +1,9 @@ # Revision history for stack-clean-old-work -## 0.2.1 (2020-11-11)+## 0.2.2 (2002-12-31)+- add 'project remove-work' to recursively remove .stack-work from projects++## 0.2.1 (2020-11-14) - remove-earlier-minor can now take a major version - major internal refactors with VersionSnapshots type - split code into modules
README.md view
@@ -33,6 +33,9 @@  NB: If you remove all snapshot builds for a version of ghc, then you would have to rebuild again for any projects still using them, so removal should be used cautiously, but it can recover a lot of diskspace. +NBB: All the command support `--dryrun` (`-n`) so you can check the effect+of running them safely beforehand.+ ### Example usage To remove project builds for ghc-8.2.2: ```@@ -68,6 +71,9 @@ The preservation/deletion is calculated and done per ghc version.  NB: If you regularly build your project for several branches/tags against the same LTS or ghc version then it is safer to avoid using `remove-older`.++Also `stack-clean-old project remove-work` can be used to recursively remove+all `.stack-work/` dirs from a project to save space.  ## Installation 
src/Main.hs view
@@ -27,6 +27,8 @@         cleanMinorSnapshots . setStackWorkDir <$> dirOption <*> dryrun <*> optional ghcVerArg       , Subcommand "remove-older" "Purge older builds in .stack-work/install" $         cleanOldStackWork <$> dryrun <*> keepOption <*> optional (strArg "PROJECTDIR")+      , Subcommand "remove-work" "Remove .stack-work subdirs recursively" $+        removeStackWorks <$> dryrun <*> optional (strArg "PROJECTDIR")       ]     , Subcommand "snapshots" "Commands for ~/.stack/snapshots" $       subcommands
src/Snapshots.hs view
@@ -10,7 +10,8 @@   setStackSnapshotsDir,   setStackWorkDir,   sizeSnapshots,-  sizeStackWork+  sizeStackWork,+  removeStackWorks   ) where @@ -158,9 +159,19 @@  setStackWorkDir :: Maybe FilePath -> IO () setStackWorkDir mdir = do-  whenJust mdir $ \ dir -> setCurrentDirectory dir+  whenJust mdir setCurrentDirectory   switchToSystemDirUnder stackWorkInstall  setStackSnapshotsDir :: IO () setStackSnapshotsDir = do   getStackSubdir "snapshots" >>= switchToSystemDirUnder++removeStackWorks :: Bool -> Maybe FilePath -> IO ()+removeStackWorks dryrun mdir = do+  whenJust mdir setCurrentDirectory+  workdirs <- sort <$> cmdLines "find" ["-type", "d", "-name", ".stack-work"]+  unless (null workdirs) $ do+    mapM_ putStrLn workdirs+    putStr "Press Enter to delete these dirs: "+    void getLine+    mapM_ (Remove.doRemoveDirectory dryrun) workdirs
stack-clean-old.cabal view
@@ -1,5 +1,5 @@ name:                stack-clean-old-version:             0.2.1+version:             0.2.2 synopsis:            Clean away old stack build artefacts description:         A tool for cleaning away old .stack snapshots and .stack-work builds@@ -30,7 +30,7 @@                        Snapshots                        Versions   hs-source-dirs:      src-  build-depends:       base < 5+  build-depends:       base >= 4.8 && < 5                      , directory >= 1.2.5                      , extra >= 1.4.3                      , filepath