mirror of
https://github.com/github/semantic.git
synced 2024-12-19 04:41:47 +03:00
Ensure we treat /dev/null as empty.
This commit is contained in:
parent
1f26be577a
commit
0e2c418038
@ -29,6 +29,7 @@ import Text.Read
|
||||
|
||||
-- | Read a utf8-encoded file to a 'Blob'.
|
||||
readFile :: forall m. MonadIO m => FilePath -> Maybe Language -> m Blob.Blob
|
||||
readFile path@"/dev/null" _ = pure (Blob.emptyBlob path)
|
||||
readFile path language = do
|
||||
raw <- liftIO $ (Just <$> B.readFile path) `catch` (const (pure Nothing) :: IOException -> IO (Maybe B.ByteString))
|
||||
pure $ fromMaybe (Blob.emptyBlob path) (Blob.sourceBlob path language . fromBytes <$> raw)
|
||||
|
Loading…
Reference in New Issue
Block a user