ashald / EnvFile

EnvFile 3.x is a plugin for JetBrains IDEs that allows you to set environment variables for your run configurations from one or multiple files.
MIT License
539 stars 129 forks source link

"Single variable" Env Provider Type #90

Closed tejoha closed 1 year ago

tejoha commented 5 years ago

See pull request #77

Added a new "env provider type" to set a single environment variable by a selected option. Sample implementation: "IP".

EnvFilejpg

ashald commented 5 years ago

Thank you for the contribution! I will try my best to find time to review it as soon as possible.

ashald commented 5 years ago

Just a heads up: my laptop is been stuck in Apple repair chain and my OSS activity is suspended until it’s back. I appreciate the contribution and eager to get it merged!

ashald commented 4 years ago

I'm super sorry for a late reply - don't have much spare time to maintain the plugin so it took me a while to get back to this.

First of all, thank you again for spending your time on contributing to the plugin.

Could you please take a look at this comment https://github.com/ashald/EnvFile/pull/92#issuecomment-606350489 - do you think using same approach could address your use-case? As mentioned in by the link, I believe that the less code is better and while merging this PR would've provided some convenience, given that similar functionality can be achieved by executing external tools by an IDE in an automated way, I'd rather err on the side of not merging the PR.

Please let me know what do you think about it.

tejoha commented 4 years ago

I tried it a little bit and found a Issue:

  1. I created a small shell script like you, but added a sleep command

    sleep 5
    echo "Foo=$(Date)" > src/dev.env
  2. Created a simple Java program

    public class Foo {
    public static empty main(String[] args) {
        System.out.println(System.getenv("Foo"));
    }
    }
  3. Addd the script to "Before Launch" image

The problem is that the IDE just launches the script, but doesn't wait for it to finish. The Java program (and the EnvFile plugin) is executed before the script has finished. So the EnvFile plugin cannot read the current version file. I think this is also the reason for the PR https://github.com/ashald/EnvFile/pull/92

ashald commented 4 years ago

Great catch, thanks! I will keep looking into it.

ashald commented 1 year ago

It's been forever, but FWIW I now think that plugin should evolve to support more sources. I'm not sure about "single-value" though, and rather think about allowing plugin to run scripts so that you can could generate whatever env vars you want to output them via stdout. This way, you could make network calls, run system utils [to get the IP address], etc. With that in mind I'll be rejecting this PR, but keep an eye on the plugin updates for new functionality.