Skip to content

Conversation

@mrvus
Copy link

@mrvus mrvus commented Jul 30, 2025

PR Checklist

Overview

@johnnyreilly
Copy link
Owner

First of all, thanks for the contribution!

How do you see this mechanism working for the scenario where a users token expires, and their generating a new one? If I read the approach in here correctly, won't we end up with expired tokens sat in the users .npmrc?

@mrvus
Copy link
Author

mrvus commented Aug 1, 2025

Hi @johnnyreilly, PR updated, i've added a new function to do the auth block amending "appendAuthBlockContent", this function manages npm authentication blocks in .npmrc files by:

Replacing existing auth blocks: If one or more auth token blocks are found (marked with ; begin auth token and ; end auth token), it replaces all of them with a single new auth block to prevent duplicates.

Appending to existing content: If no auth blocks exist but there's other content in the file, it appends the new auth block with proper newline handling.

Creating new content: If the file is empty or doesn't exist, it returns just the new auth block.

Key behaviour: When multiple auth blocks exist, they are consolidated into exactly one auth block at the position of the first block found, eliminating duplicate authentication entries.

@johnnyreilly
Copy link
Owner

Thanks @mrvus! I'm about to go on holidays and so I might not look at this immediately, but I will look at it. Ping me if I forget

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀 Feature: update users .npmrc in place instead of replacing it

2 participants