Assume -d params are strings if they don't otherwise parse

This commit is contained in:
Nick O'Leary
2020-06-04 00:04:41 +01:00
parent c0f4e07e10
commit c8f6100a6a

View File

@@ -153,7 +153,12 @@ if (parsedArgs.define) {
var match = /^(([^=]+)=(.+)|@(.*))$/.exec(def); var match = /^(([^=]+)=(.+)|@(.*))$/.exec(def);
if (match) { if (match) {
if (!match[4]) { if (!match[4]) {
var val = JSON.parse(match[3]); var val = match[3];
try {
val = JSON.parse(match[3]);
} catch(err) {
// Leave it as a string
}
RED.util.setObjectProperty(settings, match[2], val, true); RED.util.setObjectProperty(settings, match[2], val, true);
} else { } else {
var obj = fs.readJsonSync(match[4]); var obj = fs.readJsonSync(match[4]);