mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2024-11-24 07:51:01 -05:00
npmrc in RUNNER_TEMP
This commit is contained in:
parent
1be350f27e
commit
985b557393
2 changed files with 10 additions and 3 deletions
|
@ -13,7 +13,7 @@ const path = __importStar(require("path"));
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const github = __importStar(require("@actions/github"));
|
const github = __importStar(require("@actions/github"));
|
||||||
function configAuthentication(registryUrl) {
|
function configAuthentication(registryUrl) {
|
||||||
const npmrc = path.resolve(process.cwd(), '.npmrc');
|
const npmrc = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), '.npmrc');
|
||||||
writeRegistryToFile(registryUrl, npmrc);
|
writeRegistryToFile(registryUrl, npmrc);
|
||||||
}
|
}
|
||||||
exports.configAuthentication = configAuthentication;
|
exports.configAuthentication = configAuthentication;
|
||||||
|
@ -38,7 +38,10 @@ function writeRegistryToFile(registryUrl, fileLocation) {
|
||||||
}
|
}
|
||||||
// Remove http: or https: from front of registry.
|
// Remove http: or https: from front of registry.
|
||||||
const authString = registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
|
const authString = registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
|
||||||
const registryString = scope ? `${scope}:registry=${registryUrl}` : `registry=${registryUrl}`;
|
const registryString = scope
|
||||||
|
? `${scope}:registry=${registryUrl}`
|
||||||
|
: `registry=${registryUrl}`;
|
||||||
newContents += `${registryString}${os.EOL}always-auth=true${os.EOL}${authString}`;
|
newContents += `${registryString}${os.EOL}always-auth=true${os.EOL}${authString}`;
|
||||||
fs.writeFileSync(fileLocation, newContents);
|
fs.writeFileSync(fileLocation, newContents);
|
||||||
|
core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,10 @@ import * as core from '@actions/core';
|
||||||
import * as github from '@actions/github';
|
import * as github from '@actions/github';
|
||||||
|
|
||||||
export function configAuthentication(registryUrl: string) {
|
export function configAuthentication(registryUrl: string) {
|
||||||
const npmrc: string = path.resolve(process.cwd(), '.npmrc');
|
const npmrc: string = path.resolve(
|
||||||
|
process.env['RUNNER_TEMP'] || process.cwd(),
|
||||||
|
'.npmrc'
|
||||||
|
);
|
||||||
|
|
||||||
writeRegistryToFile(registryUrl, npmrc);
|
writeRegistryToFile(registryUrl, npmrc);
|
||||||
}
|
}
|
||||||
|
@ -38,4 +41,5 @@ function writeRegistryToFile(registryUrl: string, fileLocation: string) {
|
||||||
: `registry=${registryUrl}`;
|
: `registry=${registryUrl}`;
|
||||||
newContents += `${registryString}${os.EOL}always-auth=true${os.EOL}${authString}`;
|
newContents += `${registryString}${os.EOL}always-auth=true${os.EOL}${authString}`;
|
||||||
fs.writeFileSync(fileLocation, newContents);
|
fs.writeFileSync(fileLocation, newContents);
|
||||||
|
core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue