mirror of
https://github.com/pnpm/action-setup.git
synced 2025-10-16 05:31:07 +08:00
Compare commits
1 Commits
v4.2.0
...
update-pnp
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1682287a8f |
@@ -40,11 +40,11 @@ If `run_install` is a YAML string representation of either an object or an array
|
|||||||
|
|
||||||
#### `run_install.args`
|
#### `run_install.args`
|
||||||
|
|
||||||
**Optional** (_type:_ `string[]`) Additional arguments after `pnpm [recursive] install`, e.g. `[--ignore-scripts, --strict-peer-dependencies]`.
|
**Optional** (_type:_ `string[]`) Additional arguments after `pnpm [recursive] install`, e.g. `[--frozen-lockfile, --strict-peer-dependencies]`.
|
||||||
|
|
||||||
### `package_json_file`
|
### `package_json_file`
|
||||||
|
|
||||||
**Optional** (_type:_ `string`, _default:_ `package.json`) File path to the `package.json`/[`package.yaml`](https://github.com/pnpm/pnpm/pull/1799) to read "packageManager" configuration.
|
**Optional** (_type:_ `string`, _default:_ `package.json`) File path to the `package.json` to read "packageManager" configuration.
|
||||||
|
|
||||||
### `standalone`
|
### `standalone`
|
||||||
|
|
||||||
@@ -117,9 +117,9 @@ jobs:
|
|||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v4
|
||||||
with:
|
with:
|
||||||
version: 10
|
version: 10
|
||||||
run_install:
|
run_install: |
|
||||||
- recursive: true
|
- recursive: true
|
||||||
args: [--strict-peer-dependencies]
|
args: [--frozen-lockfile, --strict-peer-dependencies]
|
||||||
- args: [--global, gulp, prettier, typescript]
|
- args: [--global, gulp, prettier, typescript]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
6
dist/index.js
vendored
6
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@@ -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, copyFile } from 'fs/promises'
|
import { rm, writeFile, mkdir } 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,7 +10,6 @@ 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 })
|
||||||
@@ -20,16 +19,6 @@ 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'], {
|
||||||
@@ -75,7 +64,6 @@ async function readTarget(opts: {
|
|||||||
if (version) {
|
if (version) {
|
||||||
if (
|
if (
|
||||||
typeof packageManager === 'string' &&
|
typeof packageManager === 'string' &&
|
||||||
packageManager.startsWith('pnpm@') &&
|
|
||||||
packageManager.replace('pnpm@', '') !== version
|
packageManager.replace('pnpm@', '') !== version
|
||||||
) {
|
) {
|
||||||
throw new Error(`Multiple versions of pnpm specified:
|
throw new Error(`Multiple versions of pnpm specified:
|
||||||
|
Reference in New Issue
Block a user