Skip to content
This repository has been archived by the owner on Jan 6, 2021. It is now read-only.

Can you unset with cross-env? #114

Closed
rws-github opened this issue Jun 1, 2017 · 7 comments
Closed

Can you unset with cross-env? #114

rws-github opened this issue Jun 1, 2017 · 7 comments

Comments

@rws-github
Copy link

I can't seem to make sure that an environment variable is undefined or has an empty value.

@kentcdodds
Copy link
Owner

kentcdodds commented Jun 1, 2017

Hi there! That's not a use case that we've ever intended to support. Is that something you can do with normal shell?

@danewilson
Copy link

v4 allowed us to effectively unset variables across environments like this: FOO='' (FOO= also worked on Linux/Mac OS but not on Windows).

v5 throws an ENOENT error when this same syntax is used (FOO= or FOO='' or FOO=""). It would be nice to have this scenario catered for in v5 as well.

@kentcdodds
Copy link
Owner

Gotcha. Could someone find out how this broke?

@danewilson
Copy link

I did what I should have done in the first place and checked the release notes for v5 and this breaking change caught my eye:

"Scripts using quotes or escape sequences will see a difference in behavior.
Switching to the second bin should resolve any issue."

Lo and behold, changing to cross-env-shell allows us to use the FOO='' behaviour as before. If this is all as expected then I'm happy for this to be closed.

@kentcdodds
Copy link
Owner

Yup, sounds right!

@turnerhayes
Copy link
Contributor

I'm still having issues with this @5.0.0; it looks like it's because of this: var envSetterRegex = /(\w+)=('(.+)'|"(.+)"|(.+))/;

Instead of .* it expects at least one character. Still happens using cross-env-shell.

@kentcdodds
Copy link
Owner

Ah yes, that's a bug. Happy to accept a pull request to change that + to *

kentcdodds pushed a commit that referenced this issue Jun 8, 2017
The regex was using .+, which meant that it wasn't possible to unset variables.

Closes #114, Closes #116
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants