mirror of
https://github.com/github/semantic.git
synced 2024-12-26 08:25:19 +03:00
🔥 project entry points.
This commit is contained in:
parent
f490cddddd
commit
19eb04c51e
@ -9,7 +9,6 @@ data Project = Project
|
|||||||
{ projectRootDir :: FilePath
|
{ projectRootDir :: FilePath
|
||||||
, projectFiles :: [File]
|
, projectFiles :: [File]
|
||||||
, projectLanguage :: Language
|
, projectLanguage :: Language
|
||||||
, projectEntryPoints :: [File]
|
|
||||||
, projectExcludeDirs :: [FilePath]
|
, projectExcludeDirs :: [FilePath]
|
||||||
}
|
}
|
||||||
deriving (Eq, Ord, Show)
|
deriving (Eq, Ord, Show)
|
||||||
|
@ -183,7 +183,7 @@ parsePackage parser project@Project{..} = do
|
|||||||
|
|
||||||
-- | Parse all files in a project into 'Module's.
|
-- | Parse all files in a project into 'Module's.
|
||||||
parseModules :: Member (Distribute WrappedTask) effs => Parser term -> Project -> Eff effs [Module term]
|
parseModules :: Member (Distribute WrappedTask) effs => Parser term -> Project -> Eff effs [Module term]
|
||||||
parseModules parser Project{..} = distributeFor (projectEntryPoints <> projectFiles) (WrapTask . parseModule parser (Just projectRootDir))
|
parseModules parser Project{..} = distributeFor projectFiles (WrapTask . parseModule parser (Just projectRootDir))
|
||||||
|
|
||||||
-- | Parse a file into a 'Module'.
|
-- | Parse a file into a 'Module'.
|
||||||
parseModule :: (Member Files effs, Member Task effs) => Parser term -> Maybe FilePath -> File -> Eff effs (Module term)
|
parseModule :: (Member Files effs, Member Task effs) => Parser term -> Maybe FilePath -> File -> Eff effs (Module term)
|
||||||
|
@ -100,12 +100,12 @@ readBlobFromPath file = do
|
|||||||
readProjectFromPaths :: MonadIO m => Maybe FilePath -> FilePath -> Language -> [FilePath] -> m Project
|
readProjectFromPaths :: MonadIO m => Maybe FilePath -> FilePath -> Language -> [FilePath] -> m Project
|
||||||
readProjectFromPaths maybeRoot path lang excludeDirs = do
|
readProjectFromPaths maybeRoot path lang excludeDirs = do
|
||||||
isDir <- isDirectory path
|
isDir <- isDirectory path
|
||||||
let (filterFun, entryPoints, rootDir) = if isDir
|
let rootDir = if isDir
|
||||||
then (id, [], fromMaybe path maybeRoot)
|
then fromMaybe path maybeRoot
|
||||||
else (filter (/= path), [toFile path], fromMaybe (takeDirectory path) maybeRoot)
|
else fromMaybe (takeDirectory path) maybeRoot
|
||||||
|
|
||||||
paths <- liftIO $ filterFun <$> findFilesInDir rootDir exts excludeDirs
|
paths <- liftIO $ findFilesInDir rootDir exts excludeDirs
|
||||||
pure $ Project rootDir (toFile <$> paths) lang entryPoints excludeDirs
|
pure $ Project rootDir (toFile <$> paths) lang excludeDirs
|
||||||
where
|
where
|
||||||
toFile path = File path lang
|
toFile path = File path lang
|
||||||
exts = extensionsForLanguage lang
|
exts = extensionsForLanguage lang
|
||||||
|
Loading…
Reference in New Issue
Block a user