From 517ed7d211d62b444cb2d18144d1f108482c1aec Mon Sep 17 00:00:00 2001 From: Maurice Kelly Date: Tue, 28 Feb 2017 19:27:47 +0000 Subject: [PATCH] Include mixEnv parameter and apply to environment --- README.md | 2 ++ lib/init.js | 7 +++++++ package.json | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/README.md b/README.md index 89bc276..b8fc51f 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,8 @@ Plugin should work with default settings. If not: 5. `always use elixirc` option - leave it disabled, unless `mix compile` is too slow. +6. `mix env` option - Allows changing the Mix environment for lint runs. If using IEx at the same time as Atom this can be changed to allow IEx to pick up code changes. + ## Usage If you open folder with mix project (`mix.exs` exists in project's root diff --git a/lib/init.js b/lib/init.js index 0424621..17bea42 100644 --- a/lib/init.js +++ b/lib/init.js @@ -13,6 +13,7 @@ const elixirProjectPathCache = new Map(); let elixircPath; let mixPath; let forceElixirc; +let mixEnv; function regexp(string, flags) { return new RegExp( @@ -243,6 +244,7 @@ const getOpts = async filePath => ({ throwOnStdErr: false, stream: 'both', allowEmptyStderr: true, + env: { MIX_ENV: mixEnv }, }); const getDepsPa = async (filePath) => { @@ -322,6 +324,11 @@ export default { forceElixirc = value; }), ); + this.subscriptions.add( + atom.config.observe('linter-elixirc.mixEnv', (value) => { + mixEnv = value; + }), + ); }, deactivate() { diff --git a/package.json b/package.json index e21896e..bb37518 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,12 @@ "title": "Always use elixirc", "description": "Activating this will force the plugin to never use `mix compile` and always use `elixirc`.", "default": false + }, + "mixEnv": { + "type": "string", + "title": "Mix environment to use for linting", + "description": "Setting the Mix environment can avoid collisions between linter compiles and IEx sessions.", + "default": "dev" } }, "providedServices": {