File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4343 (map (fn [build-command ] (build-command arguments file-path ))
4444 commands )))
4545
46+ # TODO: Replace reduce with something else.
4647(defn run-commands [plan file-path arguments ]
4748 (def commands (build-commands arguments file-path ))
4849 (def errors (filter identity (flatten (map (fn [c ] (c :errors )) commands ))))
49- (if (any? errors )
50- (do
51- (errors/print-errors-without-status-code errors )
52- plan )
53- (reduce (fn [new-plan command-and-arguments ]
54- (def command (first (command-and-arguments :command )))
55- (def arguments (drop 1 (command-and-arguments :command )))
56- (apply command new-plan arguments ))
57- plan
58- commands )))
50+ (var new-plan plan )
51+ (if (empty? errors )
52+ (set new-plan (reduce (fn [new-plan command-and-arguments ]
53+ (def command (first (command-and-arguments :command )))
54+ (def arguments (drop 1 (command-and-arguments :command )))
55+ (apply command new-plan arguments ))
56+ plan
57+ commands )))
58+ {:plan new-plan :errors errors })
Original file line number Diff line number Diff line change 5454 (day/build-day (d/date 2020 8 2 ) @[]
5555 @[(task/build-task " Buy milk" true )])]))
5656 (def arguments {" skip-backup" true " remove-empty-days" true " insert-days" " 3" })
57- (def new-plan (run-commands plan file-path arguments ))
57+ (def { :plan new-plan :errors errors } (run-commands plan file-path arguments ))
5858 (def days (new-plan :days ))
59+ (test (empty? errors ) true )
5960 (test (length days ) 4 )
6061 (test (= (d/ +days today 2 ) ((days 0 ) :date )) true )
6162 (test (= (d/ +days today 1 ) ((days 1 ) :date )) true )
7071 (day/build-day (d/date 2020 8 2 ) @[]
7172 @[(task/build-task " Buy milk" true )])]))
7273 (def arguments {" skip-backup" true " remove-empty-days" true " insert-days" " three" })
73- (def new-plan (run-commands plan file-path arguments ))
74+ (def { :plan new-plan :errors errors } (run-commands plan file-path arguments ))
7475 (def days (new-plan :days ))
7576 (test (length days ) 3 )
7677 (test (= today ((days 0 ) :date )) true )
7778 (test (= (d/date 2020 8 4 ) ((days 1 ) :date )) true )
78- (test (= (d/date 2020 8 2 ) ((days 2 ) :date )) true ))
79+ (test (= (d/date 2020 8 2 ) ((days 2 ) :date )) true )
80+ (test (= (first errors ) " --insert-days argument is not a number." ) true ))
You can’t perform that action at this time.
0 commit comments