akash-akya / ex_cmd

ExCmd is an Elixir library to run external programs and to communicate with back pressure
MIT License
65 stars 3 forks source link

Fix :input function arity error when using Stream.resource/3 #20

Closed bfolkens closed 1 year ago

bfolkens commented 1 year ago

Currently, passing a Stream.resource/3 (or other simple stream items) results in the following error (#18):

** (ArgumentError) :input must be either Enumerable or a function with arity 1
    (ex_cmd 0.8.0) lib/ex_cmd/stream.ex:65: ExCmd.Stream.start_input_streamer/2
    (ex_cmd 0.8.0) lib/ex_cmd/stream.ex:44: ExCmd.Stream.__build__/2
    iex:4: (file)

It looks like the functions tried in ExCmd.Stream.start_input_streamer/2 are failing because of some logic and the order they're defined. This patch fixes the logic and adds a test to catch the case with certain types of Streams.

akash-akya commented 1 year ago

Thanks for the contribution. I'll try to cut a version within a few days.