module System.TrackedFiles
( allFiles
, trackedFiles
, untrackedFiles
) where
import qualified Control.Monad as M
import Control.Monad.IO.Class (MonadIO, liftIO)
import qualified Data.List as L
import qualified System.Directory as D
import qualified System.Process as Process
allFiles :: MonadIO m => m [FilePath]
allFiles = L.sort <$> filesThatExist files
where
filesThatExist = liftIO . (M.filterM D.doesFileExist =<<)
files = (<>) <$> trackedFiles <*> untrackedFiles
trackedFiles :: MonadIO m => m [FilePath]
trackedFiles = liftIO $ lines <$> Process.readProcess "git" ["ls-files"] []
untrackedFiles :: MonadIO m => m [FilePath]
untrackedFiles =
liftIO $
lines <$>
Process.readProcess "git" ["ls-files", "--others", "--exclude-standard"] []