Skip to content
Snippets Groups Projects
Commit 0e9f377b authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Support legacy scripts (e.g. webInit.js) thtat just load('modopts.js')

without passing any parameters (just returns null)

Throw an exception in get_mod_options() if passed a falsey modname.
parent 2f23d9d8
No related branches found
No related tags found
No related merge requests found
...@@ -40,6 +40,8 @@ ...@@ -40,6 +40,8 @@
"use strict"; "use strict";
function get_mod_options(modname, optname, default_optval) function get_mod_options(modname, optname, default_optval)
{ {
if(!modname)
throw new Error("No module name specified");
var ini_file = new File(system.ctrl_dir + "modopts/" + modname.replace(":", "-") + ".ini"); var ini_file = new File(system.ctrl_dir + "modopts/" + modname.replace(":", "-") + ".ini");
if(ini_file.open("r")) { if(ini_file.open("r")) {
var obj = ini_file.iniGetObject(/* lowercase */false, /* blanks: */true); var obj = ini_file.iniGetObject(/* lowercase */false, /* blanks: */true);
...@@ -84,4 +86,5 @@ function get_mod_options(modname, optname, default_optval) ...@@ -84,4 +86,5 @@ function get_mod_options(modname, optname, default_optval)
return val; return val;
} }
get_mod_options(argv[0], argv[1], argv[2]); if(argv.length)
get_mod_options.apply(null, argv);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment