@@ -25,7 +25,7 @@ defmodule IEx.Helpers do
25
25
* `t/1` — prints type information
26
26
* `v/0` - prints all commands and values
27
27
* `v/1` - retrieves nth value from console
28
- * `import_file/1`, `import_file/2` - evaluate the given file in the shell's context
28
+ * `import_file/1` - evaluate the given file in the shell's context
29
29
30
30
Help for functions in this module can be consulted
31
31
directly from the command line, as an example, try:
@@ -375,13 +375,9 @@ defmodule IEx.Helpers do
375
375
376
376
@ doc """
377
377
Evaluates the contents of file at `path` as if it were directly typed into
378
- the shell. When `relative_to` is provided, `path` is treated as being
379
- relative to that (unless it is already an absolute path). See `Path.expand`
380
- for more details.
378
+ the shell. `path` has to be a literal binary.
381
379
382
- Both `path` and `relative_to` (if present) have to be literal binaries.
383
-
384
- Leading `~` in `path` and `relative_to` is automatically expanded.
380
+ Leading `~` in `path` is automatically expanded.
385
381
386
382
## Examples
387
383
@@ -394,22 +390,12 @@ defmodule IEx.Helpers do
394
390
iex(2)> value
395
391
13
396
392
"""
397
- defmacro import_file ( path , relative_to // nil )
398
-
399
- defmacro import_file ( path , relative_to )
400
- when is_binary ( path ) and ( nil? ( relative_to ) or is_binary ( relative_to ) ) do
401
- if relative_to do
402
- inject_file Path . expand ( path , relative_to )
403
- else
404
- inject_file Path . expand ( path )
405
- end
406
- end
407
-
408
- defmacro import_file ( _ , _ ) do
409
- raise "import_file expects literal binaries as its arguments"
393
+ defmacro import_file ( path ) when is_binary ( path ) do
394
+ path = Path . expand ( path )
395
+ Code . string_to_ast! File . read! ( path ) , file: path
410
396
end
411
397
412
- defp inject_file ( path ) do
413
- Code . string_to_ast! File . read! ( path ) , file: path
398
+ defmacro import_file ( _ ) do
399
+ raise "import_file/1 expects a literal binary as its argument"
414
400
end
415
401
end
0 commit comments