turtle 1.5.13 → 1.5.14
raw patch · 3 files changed
+39/−6 lines, 3 filesdep ~Win32dep ~clockdep ~optparse-applicative
Dependency ranges changed: Win32, clock, optparse-applicative, semigroups
Files
- CHANGELOG.md +6/−0
- src/Turtle/Prelude.hs +31/−4
- turtle.cabal +2/−2
CHANGELOG.md view
@@ -1,3 +1,9 @@+1.5.14++* Fix `cptree` to copy symlinks instead of descending into them+ * See: https://github.com/Gabriel439/Haskell-Turtle-Library/pull/344+* Build against newer versions of `Win32` package+ 1.5.13 * Fix `chmod` bug
src/Turtle/Prelude.hs view
@@ -130,6 +130,7 @@ #if !defined(mingw32_HOST_OS) , symlink #endif+ , isNotSymbolicLink , rm , rmdir , rmtree@@ -1095,20 +1096,46 @@ #endif +{-| Returns `True` if the given `FilePath` is not a symbolic link++ This comes in handy in conjunction with `lsif`:++ > lsif isNotSymbolicLink+-}+isNotSymbolicLink :: MonadIO io => FilePath -> io Bool+isNotSymbolicLink = fmap (not . PosixCompat.isSymbolicLink) . lstat+ -- | Copy a directory tree cptree :: MonadIO io => FilePath -> FilePath -> io () cptree oldTree newTree = sh (do- oldPath <- lstree oldTree+ oldPath <- lsif isNotSymbolicLink oldTree+ -- The `system-filepath` library treats a path like "/tmp" as a file and not -- a directory and fails to strip it as a prefix from `/tmp/foo`. Adding -- `(</> "")` to the end of the path makes clear that the path is a -- directory Just suffix <- return (Filesystem.stripPrefix (oldTree </> "") oldPath)+ let newPath = newTree </> suffix+ isFile <- testfile oldPath- if isFile- then mktree (Filesystem.directory newPath) >> cp oldPath newPath- else mktree newPath )++ fileStatus <- lstat oldPath++ if PosixCompat.isSymbolicLink fileStatus+ then do+ oldTarget <- liftIO (PosixCompat.readSymbolicLink (Filesystem.encodeString oldPath))++ mktree (Filesystem.directory newPath)++ liftIO (PosixCompat.createSymbolicLink oldTarget (Filesystem.encodeString newPath))+ else if isFile+ then do+ mktree (Filesystem.directory newPath)++ cp oldPath newPath+ else do+ mktree newPath ) -- | Remove a file rm :: MonadIO io => FilePath -> io ()
turtle.cabal view
@@ -1,5 +1,5 @@ Name: turtle-Version: 1.5.13+Version: 1.5.14 Cabal-Version: >=1.10 Build-Type: Simple License: BSD3@@ -73,7 +73,7 @@ optional-args >= 1.0 && < 2.0 , unix-compat >= 0.4 && < 0.6 if os(windows)- Build-Depends: Win32 >= 2.2.0.1 && < 2.6+ Build-Depends: Win32 >= 2.2.0.1 && < 2.9 else Build-Depends: unix >= 2.5.1.0 && < 2.8 Exposed-Modules: