stack-run-auto 0.1.1.2 → 0.1.1.3
raw patch · 3 files changed
+40/−6 lines, 3 filesdep +directorydep +filepath
Dependencies added: directory, filepath
Files
- app/Main.hs +2/−2
- src/StackRunAuto.hs +29/−3
- stack-run-auto.cabal +9/−1
app/Main.hs view
@@ -15,9 +15,9 @@ case args' of [] -> error "Usage: stack-run-auto <file>" ("--help":_) -> hPutStrLn stderr usage- (fname:_) -> run (Options fname extras)+ (fname:flags) -> run (Options fname extras flags) where- usage = unlines [ "Usage: stack-run-auto [--extra <pkg>...] <file>"+ usage = unlines [ "Usage: stack-run-auto [--extra <pkg>...] <file> [<stack-flag>...]" , "" , " --extra <pkg> Adds an extra package that couldn't be resolved" , ""
src/StackRunAuto.hs view
@@ -15,12 +15,15 @@ import Development.FileModules import Network.Wreq (defaults, getWith, param, responseBody)+import System.Directory import System.Exit+import System.FilePath import System.IO (hPutStrLn, stderr) import System.Process data Options = Options { optsFileName :: FilePath , optsExtras :: [String]+ , optsFlags :: [String] } run :: Options -> IO ()@@ -31,7 +34,11 @@ let argList = map ("--package " ++) (filter isValidPackage (uniq (packages ++ concat allPackages ++ optsExtras)))- cmd = "stack runghc " ++ optsFileName ++ " " ++ join " " argList+ cmd = unwords [ "stack runghc "+ , unwords optsFlags+ , optsFileName+ , unwords argList+ ] putStrLn cmd ph <- runCommand cmd waitForProcess ph >>= exitWith@@ -56,15 +63,34 @@ extractDependenciesVerbose :: String -> IO [String] extractDependenciesVerbose pkg = timed ("---> Found dependencies for " ++ pkg) $ do putStrLn $ "Finding dependencies for " ++ pkg ++ "..."- extractDependencies pkg+ extractDependenciesCached pkg +extractDependenciesCached :: String -> IO [String]+extractDependenciesCached = cached "extract-dependencies" extractDependencies+ modulePackageVerbose :: String -> IO (Maybe String) modulePackageVerbose "" = do putStrLn "Skipping parse error (empty string)..." return Nothing modulePackageVerbose m = timed ("---> Found package for " ++ m) $ do putStrLn $ "Finding package for " ++ m ++ "..."- modulePackage m+ modulePackageCached m++cached name fn arg = do+ home <- getHomeDirectory+ let cacheDir = home </> ".stack-run-auto" </> "module-packages"+ cachePth = cacheDir </> arg+ createDirectoryIfMissing True cacheDir+ exists <- doesFileExist cachePth+ if exists+ then read <$> readFile cachePth+ else do+ r <- fn arg+ writeFile cachePth (show r)+ return r++modulePackageCached :: String -> IO (Maybe String)+modulePackageCached = cached "module-package" modulePackage modulePackage :: String -> IO (Maybe String) modulePackage m = do
stack-run-auto.cabal view
@@ -1,5 +1,5 @@ name: stack-run-auto-version: 0.1.1.2+version: 0.1.1.3 synopsis: Initial project template from stack description: Please see README.md homepage: http://github.com/yamadapc/stack-run-auto#readme@@ -16,6 +16,8 @@ hs-source-dirs: src exposed-modules: StackRunAuto build-depends: base >= 4.7 && < 5+ , filepath+ , directory , time , process , text@@ -34,6 +36,8 @@ main-is: ModulePackage.hs ghc-options: -threaded -rtsopts -with-rtsopts=-N build-depends: base+ , filepath+ , directory , time , process , text@@ -53,6 +57,8 @@ main-is: Main.hs ghc-options: -threaded -rtsopts -with-rtsopts=-N build-depends: base+ , filepath+ , directory , time , process , text@@ -72,6 +78,8 @@ hs-source-dirs: test main-is: Spec.hs build-depends: base+ , filepath+ , directory , time , process , text