shelljs / shx

Portable Shell Commands for Node
MIT License
1.72k stars 44 forks source link

env command #166

Closed KSXGitHub closed 4 years ago

KSXGitHub commented 5 years ago

I wish to convert this verbose command:

cross-env FOO=foo BAR=bar shx command

to this:

shx env FOO=foo BAR=bar command
nfischer commented 4 years ago

Can you give a concrete example? Most shelljs commands do not examine environmental variables, and it's not clear which case you're actually hitting.

KSXGitHub commented 4 years ago

@nfischer I think you misunderstand.

Most shelljs commands do not examine environmental variables

I don't need shelljs commands to read environment variables, I need a shelljs command that sets an environment variable and spawns a subprocess with that new environment variable (similar to UNIX's env command).

For example:

shx env FOO=foo BAR=bar node -p 'console.log(process.env.FOO, process.env.BAR)'

should print foo bar.

Also, UNIX's env without any arguments would print all environment variables (so yeah, it does read).

nfischer commented 4 years ago

We only support executing ShellJS commands (so it wouldn't matter if we set env vars, those shelljs commands wouldn't use them for anything).

I believe this is a duplicate of #127.