Skip to content

Commit 3236b20

Browse files
committed
Merge branch 'v2'
2 parents b7b9d63 + 2124926 commit 3236b20

File tree

15 files changed

+67
-48
lines changed

15 files changed

+67
-48
lines changed

.github/workflows/test.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ jobs:
5858
with:
5959
version: 4.11.1
6060
dest: ~/test/pnpm
61-
bin_dest: ~/test/pnpm/.bin
62-
registry: http://registry.yarnpkg.com/
6361

6462
- name: 'Test: which'
6563
run: which pnpm && which pnpx

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ temp
88
*.temp
99
tmp.*
1010
temp.*
11+
.pnpm-store

README.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ Install PNPM package manager.
1212

1313
**Optional** Where to store PNPM files.
1414

15-
### `bin_dest`
16-
17-
**Optional** Where to store executables (`pnpm` and `pnpx` commands).
18-
19-
### `registry`
20-
21-
**Optional** (_default:_ `https://registry.npmjs.com`) Registry to download PNPM from.
22-
2315
### `run_install`
2416

2517
**Optional** (_default:_ `null`) If specified, run `pnpm install`.
@@ -50,7 +42,7 @@ Expanded path of inputs#dest.
5042

5143
### `bin_dest`
5244

53-
Expanded path of inputs#bin_dest.
45+
Location of `pnpm` and `pnpx` command.
5446

5547
## Usage example
5648

action.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ inputs:
1111
description: Where to store PNPM files
1212
required: false
1313
default: ~/setup-pnpm
14-
bin_dest:
15-
description: Where to store executables (pnpm and pnpx commands)
16-
required: false
17-
default: ~/setup-pnpm/.bin
18-
registry:
19-
description: Registry to download PNPM from
20-
required: false
21-
default: https://registry.npmjs.com
2214
run_install:
2315
description: If specified, run `pnpm install`
2416
required: false

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
"expand-tilde": "^2.0.2",
1212
"js-yaml": "^4.0.0",
1313
"ajv": "^6.12.5",
14+
"fs-extra": "^9.1.0",
1415
"@actions/core": "^1.2.6",
1516
"@types/expand-tilde": "^2.0.0",
1617
"@types/node-fetch": "^2.5.8",
1718
"@types/js-yaml": "^4.0.0",
19+
"@types/fs-extra": "^9.0.8",
1820
"@types/node": "^14.14.35"
1921
},
2022
"devDependencies": {

pnpm-lock.yaml

Lines changed: 41 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

run.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@
33
export HOME="$(pwd)"
44
export INPUT_VERSION=4.11.1
55
export INPUT_DEST='~/pnpm.temp'
6-
export INPUT_BIN_DEST='~/pnpm.temp/.bin'
7-
export INPUT_REGISTRY=https://registry.npmjs.com
86
export INPUT_RUN_INSTALL=null
97
exec node dist/index.js

src/inputs/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import { RunInstall, parseRunInstall } from './run-install'
55
export interface Inputs {
66
readonly version: string
77
readonly dest: string
8-
readonly binDest: string
9-
readonly registry: string
108
readonly runInstall: RunInstall[]
119
}
1210

@@ -19,8 +17,6 @@ const parseInputPath = (name: string) => expandTilde(getInput(name, options))
1917
export const getInputs = (): Inputs => ({
2018
version: getInput('version', options),
2119
dest: parseInputPath('dest'),
22-
binDest: parseInputPath('bin_dest'),
23-
registry: getInput('registry', options),
2420
runInstall: parseRunInstall('run_install'),
2521
})
2622

src/install-pnpm/run.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
import { spawn } from 'child_process'
22
import { execPath } from 'process'
3-
import { downloadSelfInstaller } from '../self-installer'
3+
import { join } from 'path'
4+
import { remove, ensureFile, writeFile } from 'fs-extra'
5+
import fetch from 'node-fetch'
46
import { Inputs } from '../inputs'
57

68
export async function runSelfInstaller(inputs: Inputs): Promise<number> {
7-
const cp = spawn(execPath, {
8-
env: {
9-
PNPM_VERSION: inputs.version,
10-
PNPM_DEST: inputs.dest,
11-
PNPM_BIN_DEST: inputs.binDest,
12-
PNPM_REGISTRY: inputs.registry,
13-
},
9+
const { version, dest } = inputs
10+
const target = version ? `pnpm@${version}` : 'pnpm'
11+
const pkgJson = join(dest, 'package.json')
12+
13+
await remove(dest)
14+
await ensureFile(pkgJson)
15+
await writeFile(pkgJson, JSON.stringify({ private: true }))
16+
17+
const cp = spawn(execPath, ['-', 'install', target, '--no-lockfile'], {
18+
cwd: dest,
1419
stdio: ['pipe', 'inherit', 'inherit'],
1520
})
1621

17-
const response = await downloadSelfInstaller()
22+
const response = await fetch('https://pnpm.js.org/pnpm.js')
1823
response.body.pipe(cp.stdin)
1924

2025
return new Promise((resolve, reject) => {

0 commit comments

Comments
 (0)