Skip to content

Commit

Permalink
feat: installFromDesc fails if description_file or destination_folder…
Browse files Browse the repository at this point in the history
… do not exists
  • Loading branch information
ColinFay committed Jun 12, 2024
1 parent de0b9f1 commit ff27fdb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ const installFromDesc = async function (
with_exit = true
){

// fails if description_file does not exist
if (!fs.existsSync(description_file)) {
console.error(`❌ {${description_file}} does not exist.`)
return false
}

// fails if destination_folder does not exist
if (!fs.existsSync(destination_folder)) {
console.error(`❌ {${destination_folder}} does not exist.`)
return false
}

const webR = new WebR();

await webR.init();
Expand Down
9 changes: 9 additions & 0 deletions tests/install.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,17 @@ test('installFromDesc works', async () => {
{ recursive: true, force: true }
)
};

const DESCRIPTION = path.join(__dirname, "./", "DESCRIPTION");

const package_not_installed = await installFromDesc(DESCRIPTION, temp_dir, with_exit = false);

expect(
package_not_installed
).toBe(false);

fs.mkdirSync(temp_dir);

await installFromDesc(DESCRIPTION, temp_dir, with_exit = false);

expect(
Expand Down

0 comments on commit ff27fdb

Please sign in to comment.