Skip to content

Commit f1850ea

Browse files
committed
Fix allowing for multiple input. Fix struct module references
1 parent c788f88 commit f1850ea

5 files changed

Lines changed: 32 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
## [0.24.0] - Unreleased
88

9+
### Added
10+
- Implement `sigil_r` and `Regex` module
11+
912
### Fixed
1013
- CLI now allows a comma-separated or space-separated list of paths
11-
- Implement `sigil_r` and `Regex` module
14+
- Struct not properly referenced
1215

1316
## [0.23.3] - 2016-11-18
1417

lib/elixir_script.ex

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,13 @@ defmodule ElixirScript do
5252
@spec compile(binary, Map.t) :: [binary | {binary, binary} | :ok]
5353
def compile(elixir_code, opts \\ %{}) do
5454
elixir_code
55-
|> Code.string_to_quoted!
56-
|> compile_quoted(opts)
55+
|> List.wrap
56+
|> Enum.map(fn(x) ->
57+
x
58+
|> Code.string_to_quoted!
59+
|> compile_quoted(opts)
60+
end)
61+
|> List.flatten
5762
end
5863

5964
@doc """

lib/elixir_script/cli.ex

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ defmodule ElixirScript.CLI do
66
@switches [
77
output: :binary, elixir: :boolean,
88
help: :boolean, core_path: :binary,
9-
full_build: :boolean, version: :boolean,
9+
full_build: :boolean, version: :boolean,
1010
watch: :boolean
1111
]
1212

@@ -21,13 +21,19 @@ defmodule ElixirScript.CLI do
2121
end
2222

2323
def parse_args(args) do
24-
parse = OptionParser.parse(args, switches: @switches, aliases: @aliases)
25-
26-
case parse do
27-
{ [help: true] , _ , _ } -> :help
28-
{ [version: true] , _ , _ } -> :version
29-
{ options , [input], _ } -> { input, options }
30-
_ -> :help
24+
{ options, input, errors } = OptionParser.parse(args, switches: @switches, aliases: @aliases)
25+
26+
cond do
27+
length(errors) > 0 ->
28+
:help
29+
Keyword.get(options, :help, false) ->
30+
:help
31+
Keyword.get(options, :version, false) ->
32+
:version
33+
length(input) == 0 ->
34+
:help
35+
true ->
36+
{ input, options }
3137
end
3238

3339
end
@@ -80,8 +86,9 @@ defmodule ElixirScript.CLI do
8086
ElixirScript.compile(input, compile_opts)
8187
_ ->
8288
input = input
83-
|> String.split([" ", ","], trim: true)
84-
89+
|> Enum.map(fn(x) -> String.split(x, [" ", ","], trim: true) end)
90+
|> List.flatten
91+
8592
ElixirScript.compile_path(input, compile_opts)
8693

8794
if watch do

lib/elixir_script/translator/kernel/special_forms/struct.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ defmodule ElixirScript.Translator.Struct do
1313
if ElixirScript.Translator.LexicalScope.get_module_name(env, candiate_module_name) in ElixirScript.Translator.State.list_module_names() do
1414
name = ElixirScript.Translator.LexicalScope.get_module_name(env, candiate_module_name)
1515
ident = JS.identifier(Utils.name_to_js_name(name))
16+
ElixirScript.Translator.State.add_module_reference(env.module, name)
1617
JS.member_expression(ident, ident)
1718

1819
else

lib/elixir_script/watcher.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ defmodule ElixirScript.Watcher do
4141
"." <> _ ->
4242
false
4343
_ ->
44-
path == Path.absname(Path.join([state[:input], file]))
44+
Enum.any?(List.wrap(state[:input]), fn(x) ->
45+
path == Path.absname(Path.join([x, file]))
46+
end)
4547
end
4648
end
4749
end

0 commit comments

Comments
 (0)