Skip to content

Commit f2cbb71

Browse files
authored
Merge pull request #3185 from commercialhaskell/script-on-windows
Script on windows
2 parents 352172c + 8585cca commit f2cbb71

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ Bug fixes:
7676
* `stack upload` no longer reveals your password when you type it on
7777
MinTTY-based Windows shells, such as Cygwin and MSYS2.
7878
See [#3142](https://github.com/commercialhaskell/stack/issues/3142)
79+
* `stack script`'s import parser will now properly parse files that
80+
have Windows-style line endings (CRLF)
7981

8082

8183
## 1.4.0

src/Stack/Script.hs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ scriptCmd opts go' = do
6868

6969
(targetsSet, coresSet) <-
7070
case soPackages opts of
71-
[] -> do
72-
$logError "No packages provided, using experimental import parser"
71+
[] ->
72+
-- Using the import parser
7373
getPackagesFromImports (globalResolver go) (soFile opts)
7474
packages -> do
7575
let targets = concatMap wordsComma packages
@@ -266,8 +266,15 @@ loadModuleInfo name = do
266266

267267
parseImports :: ByteString -> (Set PackageName, Set ModuleName)
268268
parseImports =
269-
fold . mapMaybe parseLine . S8.lines
269+
fold . mapMaybe (parseLine . stripCR) . S8.lines
270270
where
271+
-- Remove any carriage return character present at the end, to
272+
-- support Windows-style line endings (CRLF)
273+
stripCR bs
274+
| S8.null bs = bs
275+
| S8.last bs == '\r' = S8.init bs
276+
| otherwise = bs
277+
271278
stripPrefix x y
272279
| x `S8.isPrefixOf` y = Just $ S8.drop (S8.length x) y
273280
| otherwise = Nothing

0 commit comments

Comments
 (0)