fix(node): mirror Grok hook loader contract
This commit is contained in:
1 parent
d627b784f2
commit
f01fd92946
7 files changed
+120
-10
No files matched your search
@@ -25,6 +25,7 @@ export interface GrokHandler extends JsonObject {
|
||||
readonly command?: string;
|
||||
readonly url?: string;
|
||||
readonly timeout?: number;
|
||||
readonly env?: Record<string, string> | null;
|
||||
}
|
||||
|
||||
export interface GrokGroup extends JsonObject {
|
||||
@@ -79,7 +80,7 @@ function validateHandler(
|
||||
throw new Error(`${label} requires a non-empty url`);
|
||||
}
|
||||
validateTimeout(value.timeout, label);
|
||||
if (value.env !== undefined) {
|
||||
if (value.env !== undefined && value.env !== null) {
|
||||
if (!isObject(value.env)
|
||||
|| Object.values(value.env).some((item) => typeof item !== 'string')) {
|
||||
throw new Error(`${label} env must map names to strings`);
|
||||
|
||||
@@ -15,7 +15,12 @@ const CONFIG_FILE = 'elydora-audit.json';
|
||||
|
||||
export function grokConfigPath(): string {
|
||||
const configured = process.env.GROK_HOME;
|
||||
const grokHome = configured === undefined || configured === ''
|
||||
if (configured === '') {
|
||||
throw new Error(
|
||||
'GROK_HOME is empty; unset GROK_HOME or set it to an absolute home directory',
|
||||
);
|
||||
}
|
||||
const grokHome = configured === undefined
|
||||
? path.join(os.homedir(), '.grok')
|
||||
: path.resolve(configured);
|
||||
return path.join(grokHome, 'hooks', CONFIG_FILE);
|
||||
|
||||
Reference in new issue
Block a user