Skip to content

Commit

Permalink
tools: fix windows install of an already existing module with vpm (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm authored Nov 4, 2023
1 parent 1a53a46 commit c2a3eef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 10 additions & 2 deletions cmd/tools/vpm/install.v
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,18 @@ fn vpm_install_from_vcs(modules []string, vcs &VCS) {
if os.exists(minfo.final_module_path) {
eprintln('Warning module "${minfo.final_module_path}" already exists!')
eprintln('Removing module "${minfo.final_module_path}" ...')
os.rmdir_all(minfo.final_module_path) or {
mut err_msg := ''
$if windows {
os.execute_opt('rd /s /q ${minfo.final_module_path}') or {
err_msg = err.msg()
}
} $else {
os.rmdir_all(minfo.final_module_path) or { err_msg = err.msg() }
}
if err_msg != '' {
errors++
eprintln('Errors while removing "${minfo.final_module_path}" :')
eprintln(err)
eprintln(err_msg)
continue
}
}
Expand Down
5 changes: 0 additions & 5 deletions cmd/tools/vpm/install_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ fn test_install_from_git_url() {
}

fn test_install_already_existent() {
// FIXME: Skip this for now on Windows, as `rmdir_all` results in permission
// errors when vpm tries to remove existing modules.
$if windows {
return
}
mut res := os.execute('${v} install https://github.com/vlang/markdown')
assert res.exit_code == 0, res.output
assert res.output.contains('already exists')
Expand Down

0 comments on commit c2a3eef

Please sign in to comment.