Skip to content

Commit 985b557

Browse files
author
Danny McCormick
committed
npmrc in RUNNER_TEMP
1 parent 1be350f commit 985b557

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

lib/authutil.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const path = __importStar(require("path"));
1313
const core = __importStar(require("@actions/core"));
1414
const github = __importStar(require("@actions/github"));
1515
function configAuthentication(registryUrl) {
16-
const npmrc = path.resolve(process.cwd(), '.npmrc');
16+
const npmrc = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), '.npmrc');
1717
writeRegistryToFile(registryUrl, npmrc);
1818
}
1919
exports.configAuthentication = configAuthentication;
@@ -38,7 +38,10 @@ function writeRegistryToFile(registryUrl, fileLocation) {
3838
}
3939
// Remove http: or https: from front of registry.
4040
const authString = registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
41-
const registryString = scope ? `${scope}:registry=${registryUrl}` : `registry=${registryUrl}`;
41+
const registryString = scope
42+
? `${scope}:registry=${registryUrl}`
43+
: `registry=${registryUrl}`;
4244
newContents += `${registryString}${os.EOL}always-auth=true${os.EOL}${authString}`;
4345
fs.writeFileSync(fileLocation, newContents);
46+
core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation);
4447
}

src/authutil.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import * as core from '@actions/core';
55
import * as github from '@actions/github';
66

77
export function configAuthentication(registryUrl: string) {
8-
const npmrc: string = path.resolve(process.cwd(), '.npmrc');
8+
const npmrc: string = path.resolve(
9+
process.env['RUNNER_TEMP'] || process.cwd(),
10+
'.npmrc'
11+
);
912

1013
writeRegistryToFile(registryUrl, npmrc);
1114
}
@@ -38,4 +41,5 @@ function writeRegistryToFile(registryUrl: string, fileLocation: string) {
3841
: `registry=${registryUrl}`;
3942
newContents += `${registryString}${os.EOL}always-auth=true${os.EOL}${authString}`;
4043
fs.writeFileSync(fileLocation, newContents);
44+
core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation);
4145
}

0 commit comments

Comments
 (0)