From 8fcec7aabafaa0fc22646c1174da0dd3d863bd13 Mon Sep 17 00:00:00 2001 From: Antoine Stevan <44101798+amtoine@users.noreply.github.com> Date: Sun, 28 Jan 2024 11:33:37 +0100 Subject: [PATCH] remove the destination only if it exists (#62) - should close #61 ## Description `nupm install --force` should not try to `rm` the content of `$destination` if it does not exist. this PR adds a check for that and a test to the CI. --- .github/workflows/ci.yml | 4 +++- nupm/install.nu | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02a600e..a35146f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,4 +34,6 @@ jobs: run: version - name: Run the tests - run: nu --commands $"use ($env.PWD)/nupm/; nupm test" + run: | + nu --commands $"use ($env.PWD)/nupm/; nupm install --no-confirm --force --path ." + nu --commands $"use ($env.PWD)/nupm/; nupm test" diff --git a/nupm/install.nu b/nupm/install.nu index b2e0f76..0429500 100644 --- a/nupm/install.nu +++ b/nupm/install.nu @@ -87,7 +87,9 @@ def install-path [ let destination = $module_dir | path join $package.name if $force { - rm --recursive --force $destination + if ($destination | path exists) { + rm --recursive --force $destination + } } if ($destination | path type) == dir {