diff --git a/dist/index.js b/dist/index.js index ce27906..425614a 100644 Binary files a/dist/index.js and b/dist/index.js differ diff --git a/src/install-pnpm/run.ts b/src/install-pnpm/run.ts index 26eb44b..f5b3ae0 100644 --- a/src/install-pnpm/run.ts +++ b/src/install-pnpm/run.ts @@ -1,6 +1,6 @@ import { addPath, exportVariable } from '@actions/core' import { spawn } from 'child_process' -import { rm, writeFile, mkdir } from 'fs/promises' +import { rm, writeFile, mkdir, copyFile } from 'fs/promises' import { readFileSync } from 'fs' import path from 'path' import { execPath } from 'process' @@ -10,6 +10,7 @@ import YAML from 'yaml' export async function runSelfInstaller(inputs: Inputs): Promise { const { version, dest, packageJsonFile, standalone } = inputs + const { GITHUB_WORKSPACE } = process.env // prepare self install await rm(dest, { recursive: true, force: true }) @@ -19,6 +20,16 @@ export async function runSelfInstaller(inputs: Inputs): Promise { // we have ensured the dest directory exists, we can write the file directly await writeFile(pkgJson, JSON.stringify({ private: true })) + // copy .npmrc if it exists to install from custom registry + if (GITHUB_WORKSPACE) { + try { + await copyFile(path.join(GITHUB_WORKSPACE, '.npmrc'), path.join(dest, '.npmrc')) + } catch (error) { + // Swallow error if .npmrc doesn't exist + if (!util.types.isNativeError(error) || !('code' in error) || error.code !== 'ENOENT') throw error + } + } + // prepare target pnpm const target = await readTarget({ version, packageJsonFile, standalone }) const cp = spawn(execPath, [path.join(__dirname, 'pnpm.cjs'), 'install', target, '--no-lockfile'], {