Browse Source
Co-authored-by: Gal Schlezinger <gal@spitfire.co.il>remotes/origin/clean-multishell-on-shell-exit
![zaucy@users.noreply.github.com](/assets/img/avatar_default.png)
![GitHub](/assets/img/avatar_default.png)
11 changed files with 156 additions and 45 deletions
@ -0,0 +1,5 @@
@@ -0,0 +1,5 @@
|
||||
--- |
||||
"fnm": minor |
||||
--- |
||||
|
||||
Add `--json` to `fnm env` to output the env vars as JSON |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP |
||||
|
||||
exports[`Bash outputs json: Bash 1`] = ` |
||||
"set -e |
||||
fnm env --json > file.json" |
||||
`; |
||||
|
||||
exports[`Fish outputs json: Fish 1`] = `"fnm env --json > file.json"`; |
||||
|
||||
exports[`PowerShell outputs json: PowerShell 1`] = ` |
||||
"$ErrorActionPreference = "Stop" |
||||
fnm env --json | Out-File file.json -Encoding UTF8" |
||||
`; |
||||
|
||||
exports[`Zsh outputs json: Zsh 1`] = ` |
||||
"set -e |
||||
fnm env --json > file.json" |
||||
`; |
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
import { readFile } from "node:fs/promises" |
||||
import { join } from "node:path" |
||||
import { script } from "./shellcode/script" |
||||
import { Bash, Fish, PowerShell, WinCmd, Zsh } from "./shellcode/shells" |
||||
import testCwd from "./shellcode/test-cwd" |
||||
import describe from "./describe" |
||||
|
||||
for (const shell of [Bash, Zsh, Fish, PowerShell, WinCmd]) { |
||||
describe(shell, () => { |
||||
test(`outputs json`, async () => { |
||||
const filename = `file.json` |
||||
await script(shell) |
||||
.then( |
||||
shell.redirectOutput(shell.call("fnm", ["env", "--json"]), { |
||||
output: filename, |
||||
}) |
||||
) |
||||
.takeSnapshot(shell) |
||||
.execute(shell) |
||||
|
||||
if (shell.currentlySupported()) { |
||||
const file = await readFile(join(testCwd(), filename), "utf8") |
||||
expect(JSON.parse(file)).toEqual({ |
||||
FNM_ARCH: expect.any(String), |
||||
FNM_DIR: expect.any(String), |
||||
FNM_LOGLEVEL: "info", |
||||
FNM_MULTISHELL_PATH: expect.any(String), |
||||
FNM_NODE_DIST_MIRROR: expect.any(String), |
||||
FNM_VERSION_FILE_STRATEGY: "local", |
||||
}) |
||||
} |
||||
}) |
||||
}) |
||||
} |
Loading…
Reference in new issue