fix(install): handle 'undefined' string from openclaw config get
- getJson now treats 'undefined' string as missing value - Add try-catch to JSON.parse for robustness
This commit is contained in:
@@ -67,8 +67,12 @@ function runOpenclaw(args, { allowFail = false } = {}) {
|
|||||||
|
|
||||||
function getJson(pathKey) {
|
function getJson(pathKey) {
|
||||||
const out = runOpenclaw(["config", "get", pathKey, "--json"], { allowFail: true });
|
const out = runOpenclaw(["config", "get", pathKey, "--json"], { allowFail: true });
|
||||||
if (out == null || out === "") return undefined;
|
if (out == null || out === "" || out === "undefined") return undefined;
|
||||||
|
try {
|
||||||
return JSON.parse(out);
|
return JSON.parse(out);
|
||||||
|
} catch {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setJson(pathKey, value) {
|
function setJson(pathKey, value) {
|
||||||
|
|||||||
Reference in New Issue
Block a user