extensions icon indicating copy to clipboard operation
extensions copied to clipboard

Expect to be run at project root

Open nomeata opened this issue 4 years ago • 1 comments

I hit this problem when trying to use the getPackageExtentions function pointing to a cabal file that is not my current directory, but I can also exhibit it using the CLI:

…/ext-stats $ extensions --cabal-file-path hackage/3dmodels-0.3.0/*.cabal 
  ⓘ Extensions for each module combined with 'default-extensions'
…/ext-stats $ cd hackage/3dmodels-0.3.0
…/hackage/3dmodels-0.3.0 $ extensions --cabal-file-path *.cabal
  ⓘ Extensions for each module combined with 'default-extensions'
Graphics/Model/DirectX.hs
    OverloadedStrings
    RecordWildCards
Graphics/Model/MikuMikuDance.hs
Graphics/Model/MikuMikuDance/Loader.hs
    OverloadedStrings
Graphics/Model/MikuMikuDance/Types.hs
Graphics/Model/Obj.hs
    OverloadedStrings
    TupleSections

I would expect it to find the source code relative to the given cabal file.

Also, as a feature request, it might be nice if I can just pass a path to a directory, and it will use the (existing) logic to find the .cabal file therein.

nomeata avatar Nov 15 '20 15:11 nomeata

Perhaps getPackageExtensions could be redefined to:

import qualified Extensions
import qualified System.Directory as Directory
import qualified System.FilePath as FilePath

getPackageExtensions :: FilePath -> IO (Map FilePath Extensions.ExtensionsResult)
getPackageExtensions p
  = Directory.withCurrentDirectory (FilePath.takeBaseName p)
  $ Extensions.getPackageExtentions (FilePath.takeFileName p)

fredefox avatar Nov 18 '20 11:11 fredefox