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

Use specific exit-code, fix --dry-run logging #268

Merged
merged 3 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: restyler
version: 0.4.2.0
version: 0.4.2.1
license: MIT

language: GHC2021
Expand Down
2 changes: 1 addition & 1 deletion restyler.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack

name: restyler
version: 0.4.2.0
version: 0.4.2.1
license: MIT
license-file: LICENSE
build-type: Simple
Expand Down
2 changes: 1 addition & 1 deletion src/Restyler/CLI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ main withApp run = do
failOnDifferences <- getFailOnDifferences

if failOnDifferences
then ExitFailure 1 <$ logError "Differences found"
then ExitFailure 228 <$ logError "Differences found"
else ExitSuccess <$ logWarn "Differences found"

exitHandler :: MonadLogger m => AnnotatedException SomeException -> m ExitCode
Expand Down
30 changes: 16 additions & 14 deletions src/Restyler/Restyler/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -342,20 +342,22 @@ dockerRunRestyler r@Restyler {..} WithProgress {..} = do
[path] -> pack path
paths -> show (length paths) <> " paths"

ec <-
if dryRun
then pure ExitSuccess
else case pItem of
DockerRunPathToStdout path -> do
logRunningOn [path]
(ec, out) <- dockerRunStdout $ args <> [prefix path]
ec <$ writeFile path (fixNewline out)
DockerRunPathsOverwrite sep paths -> do
logRunningOn paths
dockerRun $ args <> ["--" | sep] <> map prefix paths
DockerRunPathOverwrite sep path -> do
logRunningOn [path]
dockerRun $ args <> ["--" | sep] <> [prefix path]
unlessDryRun f
| dryRun = pure ExitSuccess
| otherwise = f

ec <- case pItem of
DockerRunPathToStdout path -> do
logRunningOn [path]
unlessDryRun $ do
(ec, out) <- dockerRunStdout $ args <> [prefix path]
ec <$ writeFile path (fixNewline out)
DockerRunPathsOverwrite sep paths -> do
logRunningOn paths
unlessDryRun $ dockerRun $ args <> ["--" | sep] <> map prefix paths
DockerRunPathOverwrite sep path -> do
logRunningOn [path]
unlessDryRun $ dockerRun $ args <> ["--" | sep] <> [prefix path]

case ec of
ExitSuccess -> pure ()
Expand Down
Loading