@@ -11,8 +11,8 @@ import qualified Data.Text as T
11
11
import qualified Data.List.NonEmpty as NonEmpty
12
12
import qualified Hledger.Flow.Types as FlowTypes
13
13
import Hledger.Flow.Import.Types
14
- import Hledger.Flow.BaseDir (turtleBaseDir , turtleRunDir , relativeToBase )
15
- import Hledger.Flow.PathHelpers (TurtlePath , forceTrailingSlash )
14
+ import Hledger.Flow.BaseDir (relativeToBase , effectiveRunDir )
15
+ import Hledger.Flow.PathHelpers (TurtlePath , pathToTurtle )
16
16
import Hledger.Flow.DocHelpers (docURL )
17
17
import Hledger.Flow.Common
18
18
import Hledger.Flow.RuntimeOptions
@@ -39,26 +39,22 @@ inputFilePattern = Turtle.contains (Turtle.once (Turtle.oneOf pathSeparators) <>
39
39
40
40
importCSVs' :: RuntimeOptions -> TChan FlowTypes. LogMessage -> IO [TurtlePath ]
41
41
importCSVs' opts ch = do
42
- let baseImportDir = forceTrailingSlash $ (turtleBaseDir opts) </> " import"
43
- let runDir = forceTrailingSlash $ Turtle. collapse $ (turtleBaseDir opts) </> (turtleRunDir opts)
44
- let effectiveDir = if useRunDir opts
45
- then if (forceTrailingSlash $ runDir </> " import" ) == baseImportDir then baseImportDir else runDir
46
- else baseImportDir
47
- channelOutLn ch $ Turtle. format (" Collecting input files from " % Turtle. fp) effectiveDir
48
- (inputFiles, diff) <- Turtle. time $ Turtle. single . shellToList . onlyFiles $ Turtle. find inputFilePattern effectiveDir
42
+ let effectiveDir = effectiveRunDir (baseDir opts) (importRunDir opts) (useRunDir opts)
43
+ channelOutLn ch $ Turtle. format (" Collecting input files from " % Turtle. fp) $ pathToTurtle effectiveDir
44
+ (inputFiles, diff) <- Turtle. time $ Turtle. single . shellToList . onlyFiles $ Turtle. find inputFilePattern (pathToTurtle effectiveDir)
49
45
let fileCount = length inputFiles
50
46
if (fileCount == 0 ) then
51
47
do
52
48
let msg = Turtle. format (" I couldn't find any input files underneath " % Turtle. fp
53
49
% " \n\n hledger-flow expects to find its input files in specifically\n named directories.\n\n " %
54
- " Have a look at the documentation for a detailed explanation:\n " % Turtle. s) effectiveDir (docURL " input-files" )
50
+ " Have a look at the documentation for a detailed explanation:\n " % Turtle. s) (pathToTurtle effectiveDir) (docURL " input-files" )
55
51
errExit 1 ch msg []
56
52
else
57
53
do
58
54
channelOutLn ch $ Turtle. format (" Found " % Turtle. d% " input files in " % Turtle. s% " . Proceeding with import..." ) fileCount (Turtle. repr diff)
59
55
let actions = map (extractAndImport opts ch) inputFiles :: [IO TurtlePath ]
60
56
importedJournals <- parAwareActions opts actions
61
- _ <- writeIncludesUpTo opts ch effectiveDir importedJournals
57
+ _ <- writeIncludesUpTo opts ch (pathToTurtle effectiveDir) importedJournals
62
58
_ <- writeToplevelAllYearsInclude opts
63
59
return importedJournals
64
60
0 commit comments