mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2026-03-21 15:05:56 +03:00
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:
parent
53b83947a5
commit
751e4076f7
2 changed files with 11 additions and 8 deletions
|
|
@ -123,7 +123,7 @@ describe('authutil tests', () => {
|
||||||
await auth.configAuthentication('https://registry.npmjs.org/');
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
||||||
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
||||||
expect(contents).toBe(
|
expect(contents).toBe(
|
||||||
`//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/`
|
`//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/${os.EOL}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -132,7 +132,7 @@ describe('authutil tests', () => {
|
||||||
await auth.configAuthentication('https://registry.npmjs.org/');
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
||||||
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
||||||
expect(contents).toBe(
|
expect(contents).toBe(
|
||||||
`@myscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/`
|
`@myscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/${os.EOL}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -141,7 +141,7 @@ describe('authutil tests', () => {
|
||||||
await auth.configAuthentication('https://registry.npmjs.org/');
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
||||||
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
||||||
expect(contents).toBe(
|
expect(contents).toBe(
|
||||||
`@myscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/`
|
`@myscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/${os.EOL}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -151,7 +151,7 @@ describe('authutil tests', () => {
|
||||||
await auth.configAuthentication('https://registry.npmjs.org/');
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
||||||
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
||||||
expect(contents).toBe(
|
expect(contents).toBe(
|
||||||
`//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
|
`//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -161,7 +161,7 @@ describe('authutil tests', () => {
|
||||||
await auth.configAuthentication('https://registry.npmjs.org/');
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
||||||
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
||||||
expect(contents).toBe(
|
expect(contents).toBe(
|
||||||
`registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
|
`registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -171,7 +171,7 @@ describe('authutil tests', () => {
|
||||||
await auth.configAuthentication('https://registry.npmjs.org/');
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
||||||
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
||||||
expect(contents).toBe(
|
expect(contents).toBe(
|
||||||
`registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
|
`registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -184,7 +184,7 @@ describe('authutil tests', () => {
|
||||||
await auth.configAuthentication('https://registry.npmjs.org/');
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
||||||
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
||||||
expect(contents).toBe(
|
expect(contents).toBe(
|
||||||
`@otherscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
|
`@otherscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -194,7 +194,7 @@ describe('authutil tests', () => {
|
||||||
await auth.configAuthentication('https://registry.npmjs.org/');
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
||||||
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
||||||
expect(contents).toBe(
|
expect(contents).toBe(
|
||||||
`@otherscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
|
`@otherscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,9 @@ function writeRegistryToFile(registryUrl: string, fileLocation: string) {
|
||||||
registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
|
registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
|
||||||
const registryString = `${scope}registry=${registryUrl}`;
|
const registryString = `${scope}registry=${registryUrl}`;
|
||||||
newContents += `${authString}${os.EOL}${registryString}`;
|
newContents += `${authString}${os.EOL}${registryString}`;
|
||||||
|
if (newContents && !newContents.endsWith(os.EOL)) {
|
||||||
|
newContents += os.EOL;
|
||||||
|
}
|
||||||
fs.writeFileSync(fileLocation, newContents);
|
fs.writeFileSync(fileLocation, newContents);
|
||||||
core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation);
|
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
|
// Export empty node_auth_token if didn't exist so npm doesn't complain about not being able to find it
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue