Skip to content

Commit

Permalink
Upgrade to Elixir 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Devin Torres committed Jan 15, 2017
1 parent e54dcd7 commit eeb7624
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 14 deletions.
19 changes: 16 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
language: elixir
elixir:
- 1.4.0
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.1
- 1.1.0
- 1.0.5
- 1.0.4
otp_release:
- 19.2
- 19.1
- 19.0
- 18.3
- 18.2
- 18.1
- 18.0
- 17.5
- 17.4
- 17.3
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq rhino
Expand Down
4 changes: 2 additions & 2 deletions lib/execjs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ defmodule Execjs do
{ ^port, { :data, data } } ->
loop(port, acc <> data)
{ ^port, :eof } ->
send port, { self, :close }
send port, { self(), :close }
receive do: ({ ^port, :closed } -> :ok)
acc
end
end

defp compile_to_tempfile(program) do
hash = :erlang.phash2(:crypto.rand_bytes(8))
hash = :erlang.phash2(:crypto.strong_rand_bytes(8))
filename = "execjs-#{hash}.js"
path = Path.join(System.tmp_dir!, filename)
File.write! path, program
Expand Down
4 changes: 2 additions & 2 deletions lib/execjs/escape.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ defmodule Execjs.Escape do
{ ?\n, "\\n" },
{ ?\r, "\\r" },
# http://bclary.com/2004/11/07/#a-7.3
{ "\x{2028}", "\\u2028" },
{ "\x{2029}", "\\u2029" }
{ "\u2028", "\\u2028" },
{ "\u2029", "\\u2029" }
]

for { char, escaped } <- escape_map do
Expand Down
2 changes: 1 addition & 1 deletion lib/execjs/runtime.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule Execjs.Runtime do

def command, do: unquote(options[:command])

def available?, do: !!System.find_executable(command)
def available?, do: !!System.find_executable(command())

runner_path = Execjs.Runtime.runner_path(unquote(options[:runner]))
EEx.function_from_file :def, :template, runner_path, [:source]
Expand Down
2 changes: 1 addition & 1 deletion lib/execjs/runtimes.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ defmodule Execjs.Runtimes do
:undefined ->
runtime = case System.get_env("EXECJS_RUNTIME") do
nil ->
Enum.find(runtimes, &(&1.available?)) || raise RuntimeUnavailable
Enum.find(runtimes(), &(&1.available?)) || raise RuntimeUnavailable
name ->
runtime = Module.concat(__MODULE__, name)
Code.ensure_loaded?(runtime)
Expand Down
6 changes: 3 additions & 3 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ defmodule Execjs.Mixfile do
version: @version,
elixir: "~> 1.0",
description: "Run JavaScript code from Elixir",
deps: deps,
package: package]
deps: deps(),
package: package()]
end

# Configuration for the OTP application
Expand All @@ -29,7 +29,7 @@ defmodule Execjs.Mixfile do
#
# Type `mix help deps` for more examples and options
defp deps do
[{:poison, "~> 1.5"}]
[{:poison, "~> 3.1"}]
end

defp package do
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
@@ -1 +1 @@
%{"poison": {:hex, :poison, "1.5.1"}}
%{"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], []}}
2 changes: 1 addition & 1 deletion test/execjs_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule ExecjsTest do

test "eval" do
assert eval(~s(var a = "a"; a + "b")) == "ab"
assert eval(~s(\x{2028}\nvar str = "foo";\x{2029}\n))
assert eval(~s(\u2028\nvar str = "foo";\u2029\n))

assert_raise RuntimeError, fn ->
eval("xxx")
Expand Down

0 comments on commit eeb7624

Please sign in to comment.