-
Notifications
You must be signed in to change notification settings - Fork 464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow to automatically enable corepack #960
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ad28a13
allow to automatically enable corepack
Schniz 23671ef
update command docs
Schniz 09745c3
add changeset
Schniz bb15cd3
fix clippy
Schniz 265b598
don't show the value of corepack
Schniz 1caa912
fix test
Schniz e60e252
test against more shells
Schniz a030821
Make exec handle errors more nicely
Schniz fb5d62b
nicer i think
Schniz 6f163c9
set corepack as debug
Schniz 3bbac36
fix windows-style paths in Bash #390
Schniz 1e08246
fix clippy
Schniz 768aca2
run cygpath on `use` validation too
Schniz 13ea39a
trim whitespace
Schniz 18d4711
fix test?
Schniz 8ad05a1
Merge remote-tracking branch 'origin/master' into corepack-flag
Schniz 12eb4ba
fix test
Schniz 1ac0fab
add changeset
Schniz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nit pick: you can use
describe.each()
here to loop insteadhttps://jestjs.io/docs/api#describeeachtablename-fn-timeout