diff options
author | Tom Smeding <t.j.smeding@uu.nl> | 2024-07-22 10:43:21 +0200 |
---|---|---|
committer | Tom Smeding <t.j.smeding@uu.nl> | 2024-07-22 10:43:21 +0200 |
commit | 25f68eb23dd53083e84608e2b1af2109d6a260ac (patch) | |
tree | 1d3f7e8b64e5cac8c23dc57bb68b214e26c77569 /modules/zelfoverhoor | |
parent | 9a41d980622b449d41999dc8f46226c1879e00ef (diff) |
Allow failing modules if they miss data files
Diffstat (limited to 'modules/zelfoverhoor')
-rw-r--r-- | modules/zelfoverhoor/zelfoverhoor.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/modules/zelfoverhoor/zelfoverhoor.js b/modules/zelfoverhoor/zelfoverhoor.js index 03de63c..0acb322 100644 --- a/modules/zelfoverhoor/zelfoverhoor.js +++ b/modules/zelfoverhoor/zelfoverhoor.js @@ -6,7 +6,12 @@ var moddir; var dbdir=cmn.persistdir+"/zelfoverhoor"; mkdirp.sync(dbdir); -var accounts=require("./accounts.json"); +var accounts=null; +try { + accounts=require("./accounts.json"); +} catch (e) { + console.error(e); +} var SHUFFLE_QUESTIONS=false; @@ -97,6 +102,9 @@ function canAccessFile(fname){ module.exports=function(app,io,_moddir){ moddir=_moddir; + // Failed to load accounts.json + if(accounts==null)return false; + if(canAccessFile(dbdir+"/questiondb.json")&&canAccessFile(dbdir+"/questionsets.json")&&canAccessFile(dbdir+"/userlists.json")){ questiondb=JSON.parse(fs.readFileSync(dbdir+"/questiondb.json")); questionsets=JSON.parse(fs.readFileSync(dbdir+"/questionsets.json")); |