Skip to content

Commit

Permalink
feat: install fails gracefully if package is not found on the webr repo
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinFay committed Jun 12, 2024
1 parent 4c9dad0 commit 6878879
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
10 changes: 8 additions & 2 deletions rpkg/R/get_list_of_tar_gz_dependencies_for_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ get_list_of_tar_gz_dependencies_for_package <- function(

options(repos = c(webr = repos))

# Getting the list of available package
info <- utils::available.packages(contriburl = repos)

if (!pk_to_install %in% info[, "Package"]) {
return(FALSE)
}

deps <- unique(
unlist(
use.names = FALSE,
Expand All @@ -40,8 +47,7 @@ get_list_of_tar_gz_dependencies_for_package <- function(
deps
)

# Getting the list of available package
info <- utils::available.packages(contriburl = repos)


res <- data.frame(
package = character(0),
Expand Down
5 changes: 5 additions & 0 deletions src/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ const installIt = async function (
package_to_install
)

if (urlsr.values[0] === false){
console.error(`❌ {${package_to_install}} not found on the webr package repository.`)
return false
}

const paks = urlsr.values[0].values
const urls = urlsr.values[1].values
let compiled_urls = {}
Expand Down
4 changes: 4 additions & 0 deletions tests/install.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ test('installIt works', async () => {
)
};

const pkg_not_installed = await installIt("pouetpouet", temp_dir);

expect(pkg_not_installed).toBe(false);

await installIt("attempt",temp_dir);

expect(
Expand Down

0 comments on commit 6878879

Please sign in to comment.