Skip to content

Commit

Permalink
Combine update into the build and repl commands (#41)
Browse files Browse the repository at this point in the history
* Combine update into the build and repl commands, fix #31, fix #32

* Only print a message if something was done
  • Loading branch information
paf31 authored Jul 12, 2017
1 parent a13656f commit 8b542c3
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ installOrUpdate :: Text -> PackageName -> PackageInfo -> IO Turtle.FilePath
installOrUpdate set pkgName PackageInfo{ repo, version } = do
let pkgDir = ".psc-package" </> fromText set </> fromText (runPackageName pkgName) </> fromText version
exists <- testdir pkgDir
unless exists . void $ cloneShallow repo version pkgDir
unless exists . void $ do
echoT ("Updating " <> runPackageName pkgName)
cloneShallow repo version pkgDir
pure pkgDir

getTransitiveDeps :: PackageSet -> [PackageName] -> IO [(PackageName, PackageInfo)]
Expand Down Expand Up @@ -230,12 +232,6 @@ initialize = do
packageNameFromPWD =
either (const untitledPackageName) id . mkPackageName

update :: IO ()
update = do
pkg <- readPackageFile
updateImpl pkg
echoT "Update complete"

install :: String -> IO ()
install pkgName' = do
pkg <- readPackageFile
Expand Down Expand Up @@ -313,11 +309,14 @@ listSourcePaths = do
paths <- getPaths
traverse_ (echoT . pathToTextUnsafe) paths

-- | helper for calling through to @purs@
-- | Helper for calling through to @purs@
--
-- extra args will be appended to the options
-- Extra args will be appended to the options
exec :: [String] -> Bool -> [String] -> IO ()
exec execNames onlyDeps passthroughOptions = do
pkg <- readPackageFile
updateImpl pkg

paths <- getPaths
let cmdParts = tail execNames
srcParts = [ "src" </> "**" </> "*.purs" | not onlyDeps ]
Expand Down Expand Up @@ -456,9 +455,6 @@ main = do
[ Opts.command "init"
(Opts.info (pure initialize)
(Opts.progDesc "Initialize a new package"))
, Opts.command "update"
(Opts.info (pure update)
(Opts.progDesc "Update dependencies"))
, Opts.command "uninstall"
(Opts.info (uninstall <$> pkg Opts.<**> Opts.helper)
(Opts.progDesc "Uninstall the named package"))
Expand Down

0 comments on commit 8b542c3

Please sign in to comment.