Fix string option parsing with nopt v9 - #11019
#11019Fix string option parsing with nopt v9#110192005rishabh wants to merge 1 commit into
Conversation
|
I haven't looked into this totally yet but the amount of change seems way overkill 🤔 was there any upgrade guide for nopt that suggested the kind of changes that we might need to do? |
|
I couldn't find any upgrade or migration notes from nopt that covered this specific behavior change. While debugging locally, it looked like nopt v9 was treating string option values that start with
The masking/unmasking approach was my attempt to preserve the existing ember-cli behavior without changing the current command APIs or option definitions. I do agree the patch ended up being a bit heavier than I'd ideally like though. If there's a cleaner way to handle this with nopt v9, I'm definitely happy to rework or simplify it. |
|
I noticed yesterday in @bertdeblock 's PR that attempted the same thing he actually removed the test as it could be wrong 🤷 #10907 any thoughts? |
|
I think the better fix is doing what's mentioned in ember-cli/ember-exam#84 (comment), and avoid any additional "parsing" ourselves. |
|
That context helps, thanks. While debugging, it still looked like But I agree the fix ended up being heavier than ideal 😅 I’ll read through the ember-exam discussion more carefully and see if there’s a simpler way to handle this without adding extra parsing logic in ember-cli. |
This builds on top of the existing
nopt@9upgrade branch.nopt@9treats string option values beginning with--as additional flags instead of string values, which breaks cases like:--options "--split 2 --random"This patch adds a small compatibility layer in
parseArgs()that temporarily masks string option values beginning with--during parsing and restores them afterward.Verified locally with:
tests/unit/models/command-test.jsember new uses yarn when blueprint has yarn.lock)Current local result: