diff options
author | 0neGal <mail@0negal.com> | 2023-08-20 20:21:22 +0200 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2023-08-20 20:46:45 +0200 |
commit | f9c64963ac1e2dc3d5b5db7ab6ecfb5b6385bfa9 (patch) | |
tree | fe60ca2605a8503eac09f2fb3a91fd39fbb769b8 /src | |
parent | de26ca435e20502b57063104161fa15e86ac1a69 (diff) | |
download | Viper-f9c64963ac1e2dc3d5b5db7ab6ecfb5b6385bfa9.tar.gz Viper-f9c64963ac1e2dc3d5b5db7ab6ecfb5b6385bfa9.zip |
fixed packages.list() assuming packages dir exists
This generally is fine, as the folder is created on startup... IF
Northstar is installed! And so, if you start Viper for the first time or
Viper as only just extracted/created the R2Northstar folder, then the
folder wont exist, but it'll simply assume as such.
Now we actually handle this correctly.
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/packages.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/modules/packages.js b/src/modules/packages.js index f868d16..d6420b9 100644 --- a/src/modules/packages.js +++ b/src/modules/packages.js @@ -59,6 +59,13 @@ packages.split_name = (name) => { } packages.list = (dir = packages.path, no_functions) => { + update_path(); + + if (! fs.existsSync(packages.path) + || dir == "R2Northstar/packages") { + return {}; + } + let files = fs.readdirSync(dir); let package_list = {}; @@ -173,6 +180,15 @@ packages.remove = (author, package_name, version) => { packages.install = async (url, author, package_name, version) => { update_path(); + if (! fs.existsSync(packages.path)) { + console.error( + "Can't install package, packages folder doesn't exist", + "and couldn't be created" + ) + + return false; + } + let name = packages.format_name(author, package_name, version); // removes zip's and folders |