git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix psc-publish producing no modules on Windows

Fixes #1326. Amend the globRelative function to use the OS's path separator, and also to raise an error unless it was able to strip the current directory prefix successfully

commitd590b03f2c21cd05051d45035fda2cd52392b863 authorHarry Garrood <harry@garrood.me> dateMon 3 Aug 2015, 14:26 (11 years ago) parent464af8e
1 file changed+18−2
src/Language/PureScript/Publish/Utils.hs+18−2
src/Language/PureScript/Publish/Utils.hs+18−2
@@ -2,8 +2,11 @@
22module Language.PureScript.Publish.Utils where
33
44import Data.List
5−import Data.Maybe
5+import Data.Either (partitionEithers)
66import System.Directory
7+import System.Exit (exitFailure)
8+import System.IO (hPutStrLn, stderr)
9+import System.FilePath (pathSeparator)
710import qualified System.FilePath.Glob as Glob
811
912-- | Glob relative to the current directory, and produce relative pathnames.
@@ -11,7 +14,20 @@ globRelative :: Glob.Pattern -> IO [FilePath]
1114globRelative pat = do
1215 currentDir <- getCurrentDirectory
1316 filesAbsolute <- Glob.globDir1 pat currentDir
14− return (mapMaybe (stripPrefix (currentDir ++ "/")) filesAbsolute)
17+ let prefix = currentDir ++ [pathSeparator]
18+ let (fails, paths) = partitionEithers . map (stripPrefix' prefix) $ filesAbsolute
19+ if null fails
20+ then return paths
21+ else do
22+ let p = hPutStrLn stderr
23+ p "Internal error in Language.PureScript.Publish.Utils.globRelative"
24+ p "Unmatched files:"
25+ mapM_ p fails
26+ exitFailure
27+
28+ where
29+ stripPrefix' prefix dir =
30+ maybe (Left dir) Right $ stripPrefix prefix dir
1531
1632-- | Glob pattern for PureScript source files.
1733purescriptSourceFiles :: Glob.Pattern