1
0
mirror of https://github.com/pnpm/action-setup.git synced 2026-03-10 08:31:44 +08:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Khải
73d022cf87
Merge 4b568c8023 into 41ff726559 2025-10-08 07:32:56 -06:00
Adrian Riedel
41ff726559
feat: support installation from custom NPM registry (#179)
copy .npmrc from GitHub workspace if it exists so that PNPM respects custom
registry configurations when self-installing
2025-10-08 10:48:14 +02:00
Khải
4b568c8023
docs: remove v2 warning
@zkochan If you have tested that it work with newer Node.js versions, this warning can be removed.
2024-07-05 21:52:13 +07:00
3 changed files with 13 additions and 6 deletions

View File

@ -1,7 +1,3 @@
> ## :warning: Upgrade from v2!
>
> The v2 version of this action [has stopped working](https://github.com/pnpm/action-setup/issues/135) with newer Node.js versions. Please, upgrade to the latest version to fix any issues.
# Setup pnpm # Setup pnpm
Install pnpm package manager. Install pnpm package manager.

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
import { addPath, exportVariable } from '@actions/core' import { addPath, exportVariable } from '@actions/core'
import { spawn } from 'child_process' 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 { readFileSync } from 'fs'
import path from 'path' import path from 'path'
import { execPath } from 'process' import { execPath } from 'process'
@ -10,6 +10,7 @@ import YAML from 'yaml'
export async function runSelfInstaller(inputs: Inputs): Promise<number> { export async function runSelfInstaller(inputs: Inputs): Promise<number> {
const { version, dest, packageJsonFile, standalone } = inputs const { version, dest, packageJsonFile, standalone } = inputs
const { GITHUB_WORKSPACE } = process.env
// prepare self install // prepare self install
await rm(dest, { recursive: true, force: true }) await rm(dest, { recursive: true, force: true })
@ -19,6 +20,16 @@ export async function runSelfInstaller(inputs: Inputs): Promise<number> {
// we have ensured the dest directory exists, we can write the file directly // we have ensured the dest directory exists, we can write the file directly
await writeFile(pkgJson, JSON.stringify({ private: true })) 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 // prepare target pnpm
const target = await readTarget({ version, packageJsonFile, standalone }) const target = await readTarget({ version, packageJsonFile, standalone })
const cp = spawn(execPath, [path.join(__dirname, 'pnpm.cjs'), 'install', target, '--no-lockfile'], { const cp = spawn(execPath, [path.join(__dirname, 'pnpm.cjs'), 'install', target, '--no-lockfile'], {