Skip to content

Commit c4711c0

Browse files
authored
Revert "Revert "Fix repeat command with odd-sized non-map outputs (#281)" (#282)" (#283)
This reverts commit 26dd1d2.
1 parent 26dd1d2 commit c4711c0

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

src/yetibot/core/commands/collections.clj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,11 @@
670670
;; - others return an error like {:result/error}
671671
;; - others just return a plain value
672672
;; so look for all 3 forms
673-
values (map (fn [{:result/keys [value error] :as arg}]
674-
(or value error arg)) results)
673+
values (map (fn [arg]
674+
(if (map? arg)
675+
(let [{:result/keys [value error]} arg]
676+
(or value error arg))
677+
arg)) results)
675678
data (map :result/data results)
676679
]
677680
(info (pr-str (doall results)))

test/yetibot/core/test/commands/collections.clj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,4 +382,11 @@
382382
(fact
383383
"using 'unquote' collections command, it should always return 'foo\" bar';
384384
pretty sure this is a bug :)"
385-
value => "foo\" bar")))
385+
value => "foo\" bar"))
386+
387+
(let [{{:result/keys [value]} :result}
388+
(ci/command-execution-info "repeat 2 range 5"
389+
{:run-command? true})]
390+
(fact
391+
"using 'repeat' collections command on 'range 5' (an odd number of elements), it should succeed and not throw No value supplied"
392+
value => [["0" "1" "2" "3" "4"] ["0" "1" "2" "3" "4"]])))

0 commit comments

Comments
 (0)