From 7719da9081f00962f9fae04cadb16b1ba1948d7a Mon Sep 17 00:00:00 2001 From: Daisuke Fujimura Date: Wed, 17 Jan 2024 16:14:00 +0900 Subject: [PATCH] Read all files to make one regexp work on search and replace --- src/Lib.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Lib.hs b/src/Lib.hs index 85e7103..f91ad7b 100644 --- a/src/Lib.hs +++ b/src/Lib.hs @@ -21,16 +21,16 @@ import Types run :: Options -> IO () run Options {from, to, path, interactive} = do hSetBuffering stdin NoBuffering - targets <- getTargetFiles from path + targets <- getTargetFiles path re <- compileRegex from let to' = T.pack to if interactive then mapM_ (substituteInteractive re to') targets else mapM_ (substitute re to') targets -getTargetFiles :: String -> FilePath -> IO [FilePath] -getTargetFiles from path = do - (_, result, _) <- readProcessWithExitCode "git" (["grep", "-l", from, path]) [] +getTargetFiles :: FilePath -> IO [FilePath] +getTargetFiles path = do + (_, result, _) <- readProcessWithExitCode "git" ["ls-files", path] [] return (lines result) substitute ::