Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove duplicate initialisation checks #13

Merged
merged 1 commit into from Nov 16, 2018
Merged

Remove duplicate initialisation checks #13

merged 1 commit into from Nov 16, 2018

Conversation

ghost
Copy link

@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
Owner

psibi commented Nov 16, 2018

Thanks!

@psibi
Copy link
Owner

psibi commented Nov 16, 2018

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

@ghost
Copy link
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