Ensure newline after registry string in authutil

Add a newline at the end of the registry string in authutil, to ensure that it's a proper POSIX file.
This commit is contained in:
Sigurd Fosseng 2026-03-04 23:24:23 +01:00
commit 751e4076f7
2 changed files with 11 additions and 8 deletions

View file

@ -44,6 +44,9 @@ function writeRegistryToFile(registryUrl: string, fileLocation: string) {
registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
const registryString = `${scope}registry=${registryUrl}`;
newContents += `${authString}${os.EOL}${registryString}`;
if (newContents && !newContents.endsWith(os.EOL)) {
newContents += os.EOL;
}
fs.writeFileSync(fileLocation, newContents);
core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation);
// Export empty node_auth_token if didn't exist so npm doesn't complain about not being able to find it