Skip to content

Commit

Permalink
Allow version check to be skipped (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gigitsu authored Aug 7, 2024
1 parent 2249260 commit ac23b69
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Config

config :esbuild,
version: "0.17.11",
version: "0.23.0",
another: [
args: ["--version"]
]
44 changes: 25 additions & 19 deletions lib/esbuild.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule Esbuild do
# https://registry.npmjs.org/esbuild/latest
@latest_version "0.17.11"
@latest_version "0.23.0"

@moduledoc """
Esbuild is an installer and runner for [esbuild](https://esbuild.github.io).
Expand All @@ -21,10 +21,14 @@ defmodule Esbuild do
## Esbuild configuration
There are two global configurations for the esbuild application:
There are four global configurations for the esbuild application:
* `:version` - the expected esbuild version
* `:version_check` - whether to perform the version check or not.
Useful when you manage the esbuild executable with an external
tool (eg. npm)
* `:cacerts_path` - the directory to find certificates for
https connections
Expand Down Expand Up @@ -65,28 +69,30 @@ defmodule Esbuild do

@doc false
def start(_, _) do
unless Application.get_env(:esbuild, :version) do
Logger.warning("""
esbuild version is not configured. Please set it in your config files:
if Application.get_env(:esbuild, :version_check, true) do
unless Application.get_env(:esbuild, :version) do
Logger.warning("""
esbuild version is not configured. Please set it in your config files:
config :esbuild, :version, "#{latest_version()}"
""")
end
config :esbuild, :version, "#{latest_version()}"
""")
end

configured_version = configured_version()
configured_version = configured_version()

case bin_version() do
{:ok, ^configured_version} ->
:ok
case bin_version() do
{:ok, ^configured_version} ->
:ok

{:ok, version} ->
Logger.warning("""
Outdated esbuild version. Expected #{configured_version}, got #{version}. \
Please run `mix esbuild.install` or update the version in your config files.\
""")
{:ok, version} ->
Logger.warning("""
Outdated esbuild version. Expected #{configured_version}, got #{version}. \
Please run `mix esbuild.install` or update the version in your config files.\
""")

:error ->
:ok
:error ->
:ok
end
end

Supervisor.start_link([], strategy: :one_for_one, name: __MODULE__.Supervisor)
Expand Down

0 comments on commit ac23b69

Please sign in to comment.