mirror of
https://github.com/garronej/ts-ci.git
synced 2025-12-01 05:43:06 +00:00
Follow up from https://github.com/garronej/github_actions_toolkit
This commit is contained in:
commit
5297ab00ab
54 changed files with 18162 additions and 0 deletions
39
src/string_replace.ts
Normal file
39
src/string_replace.ts
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
|
||||
import { setOutputFactory } from "./outputHelper";
|
||||
|
||||
import { getActionParamsFactory } from "./inputHelper";
|
||||
|
||||
export const { getActionParams } = getActionParamsFactory({
|
||||
"inputNameSubset": [
|
||||
"input_string",
|
||||
"search_value",
|
||||
"replace_value"
|
||||
] as const
|
||||
});
|
||||
|
||||
export type Params = ReturnType<typeof getActionParams>;
|
||||
|
||||
type CoreLike = {
|
||||
debug: (message: string) => void;
|
||||
};
|
||||
|
||||
export const { setOutput } = setOutputFactory<"replace_result">();
|
||||
|
||||
export async function action(
|
||||
_actionName: "string_replace",
|
||||
params: Params,
|
||||
core: CoreLike
|
||||
): Promise<Parameters<typeof setOutput>[0]> {
|
||||
|
||||
core.debug(JSON.stringify(params));
|
||||
|
||||
const { input_string, search_value, replace_value } = params;
|
||||
|
||||
return {
|
||||
"replace_result": input_string.replace(
|
||||
new RegExp(search_value, "g"),
|
||||
replace_value
|
||||
)
|
||||
};
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue