diff --git a/Cargo.lock b/Cargo.lock index 2b9997b..d2a6e86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -297,19 +297,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "console" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c050367d967ced717c04b65d8c619d863ef9292ce0c5760028655a2fb298718c" -dependencies = [ - "encode_unicode", - "lazy_static", - "libc", - "terminal_size", - "winapi", -] - [[package]] name = "constant_time_eq" version = "0.1.5" @@ -479,19 +466,6 @@ dependencies = [ "syn", ] -[[package]] -name = "dashmap" -version = "5.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "907076dfda823b0b36d2a1bb5f90c96660a5bbcd7729e10727f07858f22c4edc" -dependencies = [ - "cfg-if", - "hashbrown", - "lock_api", - "once_cell", - "parking_lot_core", -] - [[package]] name = "diff" version = "0.1.13" @@ -560,12 +534,6 @@ dependencies = [ "winreg", ] -[[package]] -name = "encode_unicode" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" - [[package]] name = "encoding_rs" version = "0.8.31" @@ -645,7 +613,6 @@ dependencies = [ "encoding_rs_io", "env_logger", "indoc", - "insta", "junction", "log", "pretty_assertions", @@ -653,8 +620,6 @@ dependencies = [ "semver", "serde", "serde_json", - "serial_test", - "shell-escape", "sysinfo", "tar", "tempfile", @@ -680,21 +645,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "futures" -version = "0.3.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - [[package]] name = "futures-channel" version = "0.3.24" @@ -702,7 +652,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050" dependencies = [ "futures-core", - "futures-sink", ] [[package]] @@ -711,17 +660,6 @@ version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf" -[[package]] -name = "futures-executor" -version = "0.3.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - [[package]] name = "futures-io" version = "0.3.24" @@ -746,10 +684,8 @@ version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" dependencies = [ - "futures-channel", "futures-core", "futures-io", - "futures-sink", "futures-task", "memchr", "pin-project-lite", @@ -954,19 +890,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adab1eaa3408fb7f0c777a73e7465fd5656136fc93b670eb6df3c88c2c1344e3" -[[package]] -name = "insta" -version = "1.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba1e75aa1530e7385af7b2685478dece08dafb9db3b4225c753286decea83bef" -dependencies = [ - "console", - "lazy_static", - "linked-hash-map", - "similar", - "yaml-rust", -] - [[package]] name = "instant" version = "0.1.12" @@ -1043,22 +966,6 @@ dependencies = [ "cc", ] -[[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" - -[[package]] -name = "lock_api" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.17" @@ -1211,29 +1118,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-sys", -] - [[package]] name = "password-hash" version = "0.4.2" @@ -1626,32 +1510,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serial_test" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92761393ee4dc3ff8f4af487bd58f4307c9329bbedea02cac0089ad9c411e153" -dependencies = [ - "dashmap", - "futures", - "lazy_static", - "log", - "parking_lot", - "serial_test_derive", -] - -[[package]] -name = "serial_test_derive" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b6f5d1c3087fb119617cff2966fe3808a80e5eb59a8c1601d5994d66f4346a5" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "sha1" version = "0.10.5" @@ -1684,18 +1542,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "shell-escape" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f" - -[[package]] -name = "similar" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ac7f900db32bf3fd12e0117dd3dc4da74bc52ebaac97f39668446d89694803" - [[package]] name = "slab" version = "0.4.7" @@ -1705,12 +1551,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "smallvec" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" - [[package]] name = "socket2" version = "0.4.7" @@ -1799,16 +1639,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "terminal_size" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "test-log" version = "0.2.11" @@ -2267,15 +2097,6 @@ dependencies = [ "lzma-sys", ] -[[package]] -name = "yaml-rust" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" -dependencies = [ - "linked-hash-map", -] - [[package]] name = "yansi" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index 658b8ff..48fcad1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,9 +35,6 @@ anyhow = "1.0.66" [dev-dependencies] pretty_assertions = "1.3.0" duct = "0.13.5" -shell-escape = "0.1.5" -insta = "1.21.1" -serial_test = "0.9.0" test-log = "0.2.11" [build-dependencies] diff --git a/e2e/shellcode/script.ts b/e2e/shellcode/script.ts index aec7f15..3c6a7da 100644 --- a/e2e/shellcode/script.ts +++ b/e2e/shellcode/script.ts @@ -8,6 +8,7 @@ import path, { join } from "node:path" import { writeFile } from "node:fs/promises" import chalk from "chalk" import testBinDir from "./test-bin-dir.js" +import { rmSync } from "node:fs" class Script { constructor( @@ -157,6 +158,7 @@ function write(writable: Writable, text: string): Promise { export function script(shell: Pick): Script { const fnmDir = path.join(testTmpDir(), "fnm") + rmSync(join(fnmDir, "aliases"), { recursive: true, force: true }) return new Script({ fnmDir }, shell.dieOnErrors ? [shell.dieOnErrors()] : []) } diff --git a/e2e/shellcode/test-tmp-dir.ts b/e2e/shellcode/test-tmp-dir.ts index 3c56c3a..32b655e 100644 --- a/e2e/shellcode/test-tmp-dir.ts +++ b/e2e/shellcode/test-tmp-dir.ts @@ -1,4 +1,4 @@ -import { mkdirSync, rmSync } from "node:fs" +import { mkdirSync } from "node:fs" import { tmpdir } from "node:os" import { join } from "node:path" @@ -9,7 +9,6 @@ export default function testTmpDir(): string { .replace(/_+/g, "_") const tmpDir = join(tmpdir(), `shellcode/${testName}`) mkdirSync(tmpDir, { recursive: true }) - rmSync(join(tmpDir, "fnm/aliases"), { recursive: true, force: true }) return tmpDir } diff --git a/e2e/system-node.test.ts b/e2e/system-node.test.ts index 43fb0f0..67fd535 100644 --- a/e2e/system-node.test.ts +++ b/e2e/system-node.test.ts @@ -12,18 +12,7 @@ for (const shell of [Bash, Fish, PowerShell, WinCmd, Zsh]) { const t = process.platform === "darwin" && shell === Bash ? test.skip : test t(`switches to system node`, async () => { - const customNode = path.join(testBinDir(), "node") - - if ( - process.platform === "win32" && - [WinCmd, PowerShell].includes(shell) - ) { - await fs.writeFile(customNode + ".cmd", "@echo custom") - } else { - await fs.writeFile(customNode, `#!/bin/bash\n\necho "custom"\n`) - // set executable - await fs.chmod(customNode, 0o766) - } + await writeCustomNode() await script(shell) .then(shell.env({})) @@ -34,5 +23,34 @@ for (const shell of [Bash, Fish, PowerShell, WinCmd, Zsh]) { .then(testNodeVersion(shell, "custom")) .execute(shell) }) + + t(`aliasing a system node`, async () => { + writeCustomNode() + const init = script(shell).then(shell.env({})) + + await init + .then(shell.call("fnm", ["install", "v10.10.0"])) + .then(shell.call("fnm", ["use", "v10"])) + .then(shell.call("fnm", ["default", "10"])) + .execute(shell) + + await init + .then(testNodeVersion(shell, "v10.10.0")) + .then(shell.call("fnm", ["default", "system"])) + .execute(shell) + + await init.then(testNodeVersion(shell, "custom")).execute(shell) + }) }) + + async function writeCustomNode() { + const customNode = path.join(testBinDir(), "node") + if (process.platform === "win32" && [WinCmd, PowerShell].includes(shell)) { + await fs.writeFile(customNode + ".cmd", "@echo custom") + } else { + await fs.writeFile(customNode, `#!/bin/bash\n\necho "custom"\n`) + // set executable + await fs.chmod(customNode, 0o766) + } + } }