-
Notifications
You must be signed in to change notification settings - Fork 243
feat: Convert list delimiters for PATH-style env variables #93
feat: Convert list delimiters for PATH-style env variables #93
Conversation
Codecov Report
@@ Coverage Diff @@
## next #93 +/- ##
===================================
Coverage 100% 100%
===================================
Files 2 3 +1
Lines 32 43 +11
===================================
+ Hits 32 43 +11
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fantastic. Thank you!
I'm going to consider this a breaking change and merge it into next
instead so it's lumped in with the other breaking changes queued up for our next major release. Thanks!
.all-contributorsrc
Outdated
"avatar_url": "https://avatars1.githubusercontent.com/u/1715800?v=3", | ||
"profile": "https://daniel.blog", | ||
"contributions": [ | ||
"code" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, do you wanna add "test"
to this?
There are some merge conflicts with the To update the contributors table in the README, you can hand-fix the |
In Windows, env variables that represent a list (such as PATH or NODE_PATH) separate their elements using a semicolon(;), but in UNIX they're separated using a colon (:). This commit adds a conversion layer, so regardless of how the delimiter is written when calling cross-env, it will be converted to the correct platform delimiter at runtime. To interpret a colon/semicolon literally instead, preced it with a backslash, like this: "cross-env VAR=semi\\;colon\\:" BREAKING CHANGE: If an env variable has : or ; in its value, it will be converted to : on UNIX systems or ; on Windows systems. To keep the old functionality, you will need to escape those characters with a backslash. kentcdodds#80
39112ca
to
03ec006
Compare
@kentcdodds Done. The conflicts were just in the all-contributors thing, easy to fix :) It makes total sense to consider this a breaking change, I didn't see you had a separate branch for that. Glad to be of (a very little) help :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect! Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, just realized one little detail. I hope it's not too inconvenient!
src/variable.test.js
Outdated
expect(varValueConvert('foo:bar')).toBe('foo;bar') | ||
}) | ||
|
||
test(`converts a ; into a : on UNIX`, () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, could we simplify things a little bit? @hgwood and I have decided that it would be nicer if cross-env
allowed you to only use the unix notation for things and not convert the other way. That would make the implementation simpler and the API simpler. Could you back these things out and even add a test or two to make sure that ;
is not converted whether on unix or not? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, done. That was my first approach but I followed the existing logic on command.js
: https://github.com/kentcdodds/cross-env/blob/master/src/command.js#L15
You folks should also simplify that to be consistent :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we should. Want to do that? 😏
…-style), not the other way around
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect! Thank you!
* feat: Convert list delimiters for PATH-style env variables In Windows, env variables that represent a list (such as PATH or NODE_PATH) separate their elements using a semicolon(;), but in UNIX they're separated using a colon (:). This commit adds a conversion layer, so regardless of how the delimiter is written when calling cross-env, it will be converted to the correct platform delimiter at runtime. To interpret a colon/semicolon literally instead, preced it with a backslash, like this: "cross-env VAR=semi\\;colon\\:" BREAKING CHANGE: If an env variable has : or ; in its value, it will be converted to : on UNIX systems or ; on Windows systems. To keep the old functionality, you will need to escape those characters with a backslash. #80 * chore: Add myself (DanReyLop) to the contributors list * Simplified logic. Now only : (UNIX-style) are converted to ; (Windows-style), not the other way around BREAKING CHANGE: You now must escape `:` to use it in a value of you don't want it to be swapped with `;` on Windows
In Windows, env variables that represent a list (such as
PATH
orNODE_PATH
) separate their elementsusing a semicolon(
;
), but in UNIX they're separated using a colon (:
).This commit adds a conversion layer, UNIX-style delimiters (
:
) will be converted to Windows-style delimiters (;
) on Windows systems at runtime. To interpret a colon literally instead, preced it with a backslash, like this:"cross-env VAR=foo\\:bar"
BREAKING CHANGE: If an env variable has
:
in its value, it will be converted to;
on Windows systems. To keep the old functionality, you will need to escape those characters with a backslash.Closes #80
PS: Sorry for the delay, I was on vacation for a while and I didn't feel like coming near a computer :)