microsoft / ado-npm-auth

This package can automatically use the azureauth CLI to fetch tokens and update a user's .npmrc file for authenticating to Azure DevOps npm feeds.
MIT License
11 stars 9 forks source link

Handle complex azureauth output #22

Closed muiriswoulfe closed 7 months ago

muiriswoulfe commented 7 months ago

azureauth on some devices is returning a complex output, in the format below. This change ensures that ado-npm-auth will work with both this output and the one previously supported.

2 tests have been added to validate this.

By the way, the linter automatically applied some styling fixes for the test file, which I left in place. I can revert these if desired.


> project@1.0.0 npx
> azureauth --version

0.8.5.0
Stuart-Wilcox commented 7 months ago

So the complex output is just extra empty lines around the actual version info?

muiriswoulfe commented 7 months ago

So the complex output is just extra empty lines around the actual version info?

Empty lines and lines beginning with '>'. See the example in my PR description.

Stuart-Wilcox commented 7 months ago

Ah sorry I misunderstood that as being what you ran to generate the output. I think we might need to use the --silent flag on the npm exec command. Would you be able to try something like that on your system and see if it works to suppress that noisy output

muiriswoulfe commented 7 months ago

Ah sorry I misunderstood that as being what you ran to generate the output. I think we might need to use the --silent flag on the npm exec command. Would you be able to try something like that on your system and see if it works to suppress that noisy output

I tried npm exec --silent --yes azureauth -- --version and that works. That's a better solution for sure, so I'm happy to update my PR to that fix.

By the way, I found that all calls to azureauth can have this issue so the change will need to be made throughout to those calls.