Skip to content

Remove duplicate initialisation checks#13

Merged
psibi merged 1 commit intomasterfrom
unknown repository
Nov 16, 2018
Merged

Remove duplicate initialisation checks#13
psibi merged 1 commit intomasterfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Nov 15, 2018

initializeTldrPages, in app/Main.hs, contains two sequential initialisation checks (calls to tldrInitialized):

initializeTldrPages :: IO ()
initializeTldrPages = do
  initialized <- tldrInitialized
  initialized <- tldrInitialized
  unless initialized $ do
    homeDir <- getHomeDirectory
    let cloneDir = homeDir </> tldrDirName
    runProcess_ $ proc "mkdir" [cloneDir]
    runProcess_ $ setWorkingDir cloneDir $ proc "git" ["clone", repoHttpsUrl]

I was very confused as to why this is necessary and have come to the conclusion that it is a simple typo. Hence, the goal of this PR is to improve the comprehensibility of this function's definition by removing the duplicate initialisation check. The result is:

initializeTldrPages :: IO ()
initializeTldrPages = do
  initialized <- tldrInitialized
  unless initialized $ do
    homeDir <- getHomeDirectory
    let cloneDir = homeDir </> tldrDirName
    runProcess_ $ proc "mkdir" [cloneDir]
    runProcess_ $ setWorkingDir cloneDir $ proc "git" ["clone", repoHttpsUrl]

This successfully compiles and runs on my Ubuntu 18.04.1 machine, with stack 1.7.1.

@psibi psibi merged commit 4032154 into psibi:master Nov 16, 2018
@psibi
Copy link
Copy Markdown
Owner

psibi commented Nov 16, 2018

Thanks!

@psibi
Copy link
Copy Markdown
Owner

psibi commented Nov 16, 2018

@Kove-W-O-Salter Released a new version with your fix. Thanks!

@ghost
Copy link
Copy Markdown
Author

ghost commented Nov 18, 2018

Thank you. I'm glad that I could help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant