Skip to content

Commit

Permalink
Read all files to make one regexp work on search and replace
Browse files Browse the repository at this point in the history
  • Loading branch information
fujimura committed Mar 14, 2024
1 parent 4f7574c commit 7719da9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Lib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ::
Expand Down

0 comments on commit 7719da9

Please sign in to comment.