Skip to content

Commit cffedc6

Browse files
authored
Install on need verify package (#94)
* read and write add-from-bower from local package set * make add-from-bower write to local package set updates lts to use newer aeson-pretty to use trailing newline formatting * make add-from-bower write to local package set also adds a newer aeson-pretty to extra-deps to use trailing newline formatting * have verify pull dependencies per verifying package as the installation step checks to not reinstall existing packages, calling it multiple times with previously installed packages works fine. * concurrently traverse the dependencies for verify
1 parent cda2f05 commit cffedc6

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

app/Main.hs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
module Main where
1111

1212
import qualified Control.Foldl as Foldl
13-
import Control.Concurrent.Async (forConcurrently_)
13+
import Control.Concurrent.Async (forConcurrently_, mapConcurrently)
1414
import qualified Data.Aeson as Aeson
1515
import Data.Aeson.Types (fieldLabelModifier)
1616
import Data.Aeson.Encode.Pretty
@@ -474,17 +474,19 @@ verify arg = do
474474
verifyPackages names db pkg = do
475475
echoT $ "Verifying " <> pack (show $ length names) <> " packages."
476476
echoT "Warning: this could take some time!"
477-
478-
let go (name_, pkgInfo) = (name_, ) <$> performInstall (set pkg) name_ pkgInfo
479-
paths <- Map.fromList <$> traverse go (Map.toList db)
480-
traverse_ (verifyPackage db paths) names
481-
482-
verifyPackage :: PackageSet -> Map.Map PackageName Turtle.FilePath -> PackageName -> IO ()
483-
verifyPackage db paths name = do
484-
let dirFor pkgName = fromMaybe (error ("verifyPackageSet: no directory for " <> show pkgName)) (Map.lookup pkgName paths)
477+
traverse_ (verifyPackage db pkg) names
478+
479+
verifyPackage :: PackageSet -> PackageConfig -> PackageName -> IO ()
480+
verifyPackage db pkg name = do
481+
let
482+
dirFor pkgName =
483+
case Map.lookup pkgName db of
484+
Nothing -> error ("verifyPackageSet: no directory for " <> show pkgName)
485+
Just pkgInfo -> performInstall (set pkg) pkgName pkgInfo
485486
echoT ("Verifying package " <> runPackageName name)
486487
dependencies <- map fst <$> getTransitiveDeps db [name]
487-
let srcGlobs = map (pathToTextUnsafe . (</> ("src" </> "**" </> "*.purs")) . dirFor) dependencies
488+
dirs <- mapConcurrently dirFor dependencies
489+
let srcGlobs = map (pathToTextUnsafe . (</> ("src" </> "**" </> "*.purs"))) dirs
488490
procs "purs" ("compile" : srcGlobs) empty
489491

490492
data BowerInfoRepo = BowerInfoRepo

stack.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
resolver: lts-11.1
22
packages:
33
- '.'
4-
extra-deps: []
4+
extra-deps:
5+
- aeson-pretty-0.8.5 # newer in lts-11.1 needed for formatting packages.json

0 commit comments

Comments
 (0)