-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow to automatically enable corepack (#960)
* allow to automatically enable corepack * update command docs * add changeset * fix clippy * don't show the value of corepack * fix test * test against more shells * Make exec handle errors more nicely * nicer i think * set corepack as debug * fix windows-style paths in Bash #390 * fix clippy * run cygpath on `use` validation too * trim whitespace * fix test? * fix test * add changeset
- Loading branch information
Showing
21 changed files
with
331 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"fnm": minor | ||
--- | ||
|
||
Add --corepack-enabled flag for automatically enabling corepack on fnm install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"fnm": patch | ||
--- | ||
|
||
use cygwinpath to make the path posix-like on Windows Bash usage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Bash installs corepack: Bash 1`] = ` | ||
"set -e | ||
eval "$(fnm env --corepack-enabled)" | ||
fnm install 18 | ||
fnm exec --using=18 node test-pnpm-corepack.js" | ||
`; | ||
|
||
exports[`Fish installs corepack: Fish 1`] = ` | ||
"fnm env --corepack-enabled | source | ||
fnm install 18 | ||
fnm exec --using=18 node test-pnpm-corepack.js" | ||
`; | ||
|
||
exports[`PowerShell installs corepack: PowerShell 1`] = ` | ||
"$ErrorActionPreference = "Stop" | ||
fnm env --corepack-enabled | Out-String | Invoke-Expression | ||
fnm install 18 | ||
fnm exec --using=18 node test-pnpm-corepack.js" | ||
`; | ||
|
||
exports[`Zsh installs corepack: Zsh 1`] = ` | ||
"set -e | ||
eval "$(fnm env --corepack-enabled)" | ||
fnm install 18 | ||
fnm exec --using=18 node test-pnpm-corepack.js" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import fs from "fs" | ||
import { script } from "./shellcode/script.js" | ||
import { Bash, Fish, PowerShell, Zsh } from "./shellcode/shells.js" | ||
import describe from "./describe.js" | ||
import path from "path" | ||
import testCwd from "./shellcode/test-cwd.js" | ||
import { createRequire } from "module" | ||
|
||
const require = createRequire(import.meta.url) | ||
const whichPath = require.resolve("which") | ||
|
||
const nodescript = ` | ||
const which = require(${JSON.stringify(whichPath)}); | ||
const pnpmBinary = which.sync('pnpm') | ||
const nodeBinary = which.sync('node') | ||
const binPath = require('path').dirname(nodeBinary); | ||
if (!pnpmBinary.includes(binPath)) { | ||
console.log('pnpm not found in current Node.js bin', { binPath, pnpmBinary }); | ||
process.exit(1); | ||
} | ||
const scriptContents = require('fs').readFileSync(pnpmBinary, 'utf8'); | ||
console.log('scriptContents', scriptContents) | ||
if (!scriptContents.includes('corepack')) { | ||
console.log('corepack not found in pnpm script'); | ||
process.exit(1); | ||
} | ||
` | ||
|
||
for (const shell of [Bash, Fish, PowerShell, Zsh]) { | ||
describe(shell, () => { | ||
test(`installs corepack`, async () => { | ||
const cwd = testCwd() | ||
const filepath = path.join(cwd, "test-pnpm-corepack.js") | ||
fs.writeFileSync(filepath, nodescript) | ||
|
||
await script(shell) | ||
.then(shell.env({ corepackEnabled: true })) | ||
.then(shell.call("fnm", ["install", "18"])) | ||
.then( | ||
shell.call("fnm", [ | ||
"exec", | ||
"--using=18", | ||
"node", | ||
"test-pnpm-corepack.js", | ||
]) | ||
) | ||
.takeSnapshot(shell) | ||
// .addExtraEnvVar("RUST_LOG", "fnm=debug") | ||
.execute(shell) | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
c29f315
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linux Benchmarks
fnm_basic/median
20.86ms
20.81ms
+0.05ms
fnm_basic/max
28.07ms
22.75ms
+5.33ms
fnm_basic/mean
21.05ms
20.96ms
+0.09ms
fnm_basic/min
20.31ms
20.29ms
+0.02ms
fnm_basic/stddev
0.93ms
0.53ms
+0.4ms
binary size
6804kb
6772kb
+32kb