reasonml-old / dependency-env

Loads environment variables that dependencies declared as exported in their package.json
MIT License
7 stars 1 forks source link

Make `dependencyEnv` command better. #1

Open jordwalke opened 8 years ago

jordwalke commented 8 years ago

Right now, in your npm "run scripts" or Makefiles, you must do:

source dependencyEnv && some-command with-args

In order to source the variables for executing some-command.

I'd rather the command be more like the unix time command.

dependencyEnv some-command with-args

Which would spin up a new shell, source the real dependencyEnv which sets the env variables, and runs the command that was specified after.

jordwalke commented 8 years ago

@yunxing - do you have any suggestions about the best way to make a command like that?

jordwalke commented 8 years ago

How about this instead:

  1. Instead of scripts, we create a new section in the package.json called run. These scripts are always executed such that dependencyEnv is first sourced.
  2. We expose a single top level command called re which is the entry point to all of the build/install tooling. You can then execute re run yourScriptName. Alternatively, you could execute re exec your command here to execute the literal command your command here.
yunxing commented 8 years ago

@jordwalke Sorry just saw this.

An alternative is create a VirtualEnv-like program which creates a "env session" on user's current shell session.

jordwalke commented 8 years ago

Does that let you undo the changes to variables?

yunxing commented 8 years ago

Yes. We can stack the previous variables and have a separate program to pop them out when we are done with the environment.