File tree 4 files changed +24
-14
lines changed
4 files changed +24
-14
lines changed Original file line number Diff line number Diff line change
1
+ # This file on its own is not valid,
2
+ # but it can be merged with other journals
3
+ transactions :
4
+ - utc : ' 2024-05-28 14:35'
5
+ note : Bread and butter
6
+ transfers :
7
+ - from : john:giro
8
+ to : non_existant_bakery
9
+ amount : 4.19 €
Original file line number Diff line number Diff line change @@ -86,6 +86,12 @@ test-cli: | node_modules
86
86
balance examples/journal.yaml examples/journal-only-transactions.yaml \
87
87
> /dev/null
88
88
89
+ # Following command should fail
90
+ @bun x spago run -- \
91
+ balance examples/journal.yaml examples/journal-broken-transaction.yaml \
92
+ && echo "❌ This must fail" && exit 1 \
93
+ || echo "✅ Balance printed an error"
94
+
89
95
bun x spago run -- \
90
96
unused-files examples/receipts examples/journal.yaml \
91
97
2> /dev/null
Original file line number Diff line number Diff line change @@ -205,18 +205,6 @@ buildLedgerAndRun currentDir journalPathRel extraJournalPaths callback = do
205
205
Error msg -> pure $ Error msg
206
206
Ok ledger -> ledger # callback
207
207
208
- buildRunExit
209
- :: String
210
- -> String
211
- -> Array CliArgPrim
212
- -> (Ledger -> Effect (Result String Unit ))
213
- -> Effect (Result String Unit )
214
- buildRunExit currentDir journalPathRel extraJournalPaths callback = do
215
- buildLedgerAndRun currentDir journalPathRel extraJournalPaths callback
216
- >>= \res -> case res of
217
- Ok val -> pure $ Ok val
218
- Error msg -> errorAndExit config msg
219
-
220
208
getAllFiles :: String -> Effect (Array String )
221
209
getAllFiles directoryPath =
222
210
let
@@ -247,7 +235,7 @@ checkUnusedFiles
247
235
:: String -> String -> Array CliArgPrim -> Effect (Result String Unit )
248
236
checkUnusedFiles filesDirPath jourPathRel extraJournalPaths = do
249
237
currentDir <- cwd
250
- buildRunExit currentDir jourPathRel extraJournalPaths $
238
+ buildLedgerAndRun currentDir jourPathRel extraJournalPaths $
251
239
\ledger@(Ledger { transactions }) -> do
252
240
let
253
241
journalDir =
Original file line number Diff line number Diff line change @@ -357,7 +357,14 @@ callCliAppWithOutput doesPrint executor =
357
357
setExitCode 1
358
358
Ok cliSpec -> do
359
359
arguments <- argv
360
- _ <- callCliAppWith cliSpec executor doesPrint arguments
360
+ result <- callCliAppWith cliSpec executor doesPrint arguments
361
+ case result of
362
+ Error errMsg -> do
363
+ error (makeRed errMsg)
364
+ setExitCode 1
365
+ Ok val -> do
366
+ log val
367
+ setExitCode 0
361
368
pure unit
362
369
363
370
callCliAppWith
You can’t perform that action at this time.
0 commit comments