@@ -61,8 +61,14 @@ defmodule IEx.Helpers do
6161 c "baz.ex"
6262 #=> [Baz]
6363 """
64- def c ( files , path // "." ) do
65- { erls , exs } = Enum . partition ( List . wrap ( files ) , & String . ends_with? ( & 1 , ".erl" ) )
64+ def c ( files , path // "." ) when is_binary ( path ) do
65+ files = List . wrap ( files )
66+
67+ unless Enum . all? ( files , & is_binary / 1 ) do
68+ raise ArgumentError , message: "expected a binary or a list of binaries as argument"
69+ end
70+
71+ { erls , exs } = Enum . partition ( files , & String . ends_with? ( & 1 , ".erl" ) )
6672
6773 modules = Enum . map ( erls , fn ( source ) ->
6874 { module , binary } = compile_erlang ( source )
@@ -82,8 +88,8 @@ defmodule IEx.Helpers do
8288 end
8389
8490 @ doc """
85- Prints the list of all loaded modules with paths to their corresponding .beam
86- files.
91+ Prints the list of all loaded modules with paths to
92+ their corresponding `.beam` files.
8793 """
8894 def m do
8995 all = Enum . map :code . all_loaded , fn { mod , file } -> { inspect ( mod ) , file } end
@@ -283,7 +289,7 @@ defmodule IEx.Helpers do
283289 Please note that all the modules defined in the same file as `module`
284290 are recompiled and reloaded.
285291 """
286- def r ( module ) do
292+ def r ( module ) when is_atom ( module ) do
287293 case do_r ( module ) do
288294 mods when is_list ( mods ) -> { module , mods }
289295 other -> other
@@ -308,7 +314,7 @@ defmodule IEx.Helpers do
308314 Load the given module's beam code (and ensures any previous
309315 old version was properly purged before).
310316 """
311- def l ( module ) do
317+ def l ( module ) when is_atom ( module ) do
312318 :code . purge ( module )
313319 :code . load_file ( module )
314320 end
@@ -350,7 +356,7 @@ defmodule IEx.Helpers do
350356 @ doc """
351357 Changes the current working directory to the given path.
352358 """
353- def cd ( directory ) do
359+ def cd ( directory ) when is_binary ( directory ) do
354360 case File . cd ( expand_home ( directory ) ) do
355361 :ok -> pwd
356362 { :error , :enoent } ->
@@ -362,7 +368,7 @@ defmodule IEx.Helpers do
362368 Produces a simple list of a directory's contents.
363369 If `path` points to a file, prints its full path.
364370 """
365- def ls ( path // "." ) do
371+ def ls ( path // "." ) when is_binary ( path ) do
366372 path = expand_home ( path )
367373 case File . ls ( path ) do
368374 { :ok , items } ->
0 commit comments