Skip to content

Commit

Permalink
remove the destination only if it exists (#62)
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
amtoine authored Jan 28, 2024
1 parent 66e2eaa commit 8fcec7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 3 additions & 1 deletion nupm/install.nu
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8fcec7a

Please sign in to comment.