mirror of
https://github.com/ryantm/nixpkgs-update.git
synced 2024-11-10 13:24:58 +03:00
20 lines
513 B
Haskell
20 lines
513 B
Haskell
module File
|
|
( replace
|
|
) where
|
|
|
|
import Data.Text (Text)
|
|
import qualified Data.Text as T
|
|
import Data.Text.IO as T
|
|
import qualified Shelly
|
|
import Shelly (liftIO, toTextIgnore, Sh)
|
|
|
|
replaceIO :: Text -> Text -> FilePath -> IO ()
|
|
replaceIO find r file = do
|
|
contents <- T.readFile file
|
|
T.writeFile file (T.replace find r contents)
|
|
|
|
replace :: Text -> Text -> Shelly.FilePath -> Sh ()
|
|
replace find r file = liftIO $ replaceIO find r f
|
|
where
|
|
f = (T.unpack . toTextIgnore) file
|