mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Improve error handling of case where match is not found
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
632365a3b9
commit
10d44aa114
@ -149,11 +149,18 @@ const computeUnixShellEnvironmentInjectable = getInjectable({
|
||||
try {
|
||||
const rawOutput = Buffer.concat(stdout).toString("utf-8");
|
||||
|
||||
logger.info(`[UNIX-SHELL-ENV]: got the following output`, { rawOutput });
|
||||
logger.debug(`[UNIX-SHELL-ENV]: got the following output`, { rawOutput });
|
||||
|
||||
const match = regex.exec(rawOutput);
|
||||
const strippedRawOutput = match ? match[1] : "{}";
|
||||
const resolvedEnv = JSON.parse(strippedRawOutput) as Partial<Record<string, string>>;
|
||||
const matchedOutput = regex.exec(rawOutput)?.[1];
|
||||
|
||||
if (!matchedOutput) {
|
||||
return resolve({
|
||||
callWasSuccessful: false,
|
||||
error: "Something has blocked the shell from producing the environement variables",
|
||||
});
|
||||
}
|
||||
|
||||
const resolvedEnv = JSON.parse(matchedOutput) as Partial<Record<string, string>>;
|
||||
|
||||
resetEnvPairs(resolvedEnv);
|
||||
resolve({
|
||||
|
||||
Loading…
Reference in New Issue
Block a user