Refactor (#109)
This commit is contained in:
committed by
pullfrog[bot]
parent
101c666610
commit
69b9b96ddd
@@ -35,21 +35,14 @@ export async function run(inputsOrPrompt: Inputs | string): Promise<AgentResult>
|
||||
const inputs: Inputs =
|
||||
typeof inputsOrPrompt === "string" ? { prompt: inputsOrPrompt } : inputsOrPrompt;
|
||||
|
||||
// Mock core.getInput to simulate Github Actions input
|
||||
const mockCore = {
|
||||
getInput: (name: string, options?: { required?: boolean }): string => {
|
||||
const value = inputs[name as keyof Inputs];
|
||||
if (value === undefined || value === null) {
|
||||
if (options?.required) {
|
||||
throw new Error(`Input required and not supplied: ${name}`);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
return String(value);
|
||||
},
|
||||
};
|
||||
// set INPUT_* env vars for @actions/core.getInput()
|
||||
for (const [key, value] of Object.entries(inputs)) {
|
||||
if (value !== undefined && value !== null) {
|
||||
process.env[`INPUT_${key.toUpperCase()}`] = String(value);
|
||||
}
|
||||
}
|
||||
|
||||
const result = await main(mockCore);
|
||||
const result = await main();
|
||||
|
||||
process.chdir(originalCwd);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user