forked from Schniz/fnm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added json option to env command (Schniz#800)
Co-authored-by: Gal Schlezinger <[email protected]>
- Loading branch information
Showing
11 changed files
with
156 additions
and
45 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 `--json` to `fnm env` to output the env vars as JSON |
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 |
---|---|---|
|
@@ -159,6 +159,40 @@ jobs: | |
FNM_TARGET_NAME: "release" | ||
FORCE_COLOR: "1" | ||
|
||
# e2e_windows_debug: | ||
# runs-on: windows-latest | ||
# name: "e2e/windows/debug" | ||
# environment: Debug | ||
# needs: [e2e_windows] | ||
# if: contains(join(needs.*.result, ','), 'failure') | ||
# steps: | ||
# - uses: actions/checkout@v3 | ||
# - uses: actions/download-artifact@v3 | ||
# with: | ||
# name: fnm-windows | ||
# path: target/release | ||
# - uses: pnpm/[email protected] | ||
# with: | ||
# run_install: false | ||
# - uses: actions/setup-node@v3 | ||
# with: | ||
# node-version: 16.x | ||
# cache: 'pnpm' | ||
# - name: Get pnpm store directory | ||
# id: pnpm-cache | ||
# run: | | ||
# echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" | ||
# - uses: actions/cache@v3 | ||
# name: Setup pnpm cache | ||
# with: | ||
# path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} | ||
# key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
# restore-keys: | | ||
# ${{ runner.os }}-pnpm-store- | ||
# - run: pnpm install | ||
# - name: 🐛 Debug Build | ||
# uses: mxschmitt/action-tmate@v3 | ||
|
||
e2e_linux: | ||
runs-on: ubuntu-latest | ||
needs: [build_static_linux_binary] | ||
|
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,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" | ||
`; |
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,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", | ||
}) | ||
} | ||
}) | ||
}) | ||
} |
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
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