From 842650dbfe23a302ad8d10e674e7d6f189b17b46 Mon Sep 17 00:00:00 2001 From: Kevin Lewis Date: Tue, 21 Sep 2021 16:26:09 -0600 Subject: [PATCH] Provide an option for loading the runtime config Do not load the runtime configuration by default. Instead, provide an option, `--runtime-config`, for loading the runtime configuration. This mirrors the configuration in `esbuild`. --- lib/mix/tasks/sass.ex | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/mix/tasks/sass.ex b/lib/mix/tasks/sass.ex index 9cfcda8..767bee7 100644 --- a/lib/mix/tasks/sass.ex +++ b/lib/mix/tasks/sass.ex @@ -17,6 +17,10 @@ defmodule Mix.Tasks.Sass do If dart-sass is not installed, it is automatically downloaded. Note the arguments given to this task will be appended to any configured arguments. + + ## Options + * `--runtime-config` - load the runtime configuration before executing + command """ @shortdoc "Invokes sass with the profile and args" @@ -25,11 +29,16 @@ defmodule Mix.Tasks.Sass do @impl true def run([profile | args] = all) do - if Code.ensure_loaded?(Mix.Tasks.App.Config) do + switches = [runtime_config: :boolean] + {opts, remaining_args} = OptionParser.parse_head!(args, switches: switches) + + if opts[:runtime_config] do Mix.Task.run("app.config") + else + Application.ensure_all_started(:dart_sass) end - case DartSass.install_and_run(String.to_atom(profile), args) do + case DartSass.install_and_run(String.to_atom(profile), remaining_args) do 0 -> :ok status -> Mix.raise("`mix sass #{Enum.join(all, " ")}` exited with #{status}") end