From f7fe3a4e7c8f8dc1302ee94f360c2bfcbce25d67 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 3 Apr 2018 01:12:55 +0200 Subject: [PATCH] clean up environment set-up --- src/Main.hs | 10 ++++++++-- src/Utils.hs | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Main.hs b/src/Main.hs index 9774d63..c8e09d7 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -21,7 +21,13 @@ makeOptions :: Sh Options makeOptions = do dryRun <- isJust <$> get_env "DRY_RUN" workingDir <- ( ".nix-update") <$> get_env_text "HOME" - return $ Options dryRun workingDir + githubToken <- cmd "cat" "github_token.txt" + return $ Options dryRun workingDir githubToken + +setUpEnvironment :: Options -> Sh () +setUpEnvironment options = do + setenv "PAGER" "" + setenv "GITHUB_TOKEN" (githubToken options) main :: IO () main = shelly $ do @@ -32,7 +38,7 @@ main = shelly $ do mkdir_p (workingDir options) touchfile logFile - githubToken <- cmd "cat" "github_token.txt" + setUpEnvironment options updates <- cmd "cat" "packages-to-update.txt" diff --git a/src/Utils.hs b/src/Utils.hs index 9172bad..3aa343a 100644 --- a/src/Utils.hs +++ b/src/Utils.hs @@ -15,7 +15,8 @@ type Version = Text data Options = Options { dryRun :: Bool, - workingDir :: FilePath + workingDir :: FilePath, + githubToken :: Text } setupNixpkgs :: Sh FilePath