mirror of
https://github.com/kiegroup/git-backporting.git
synced 2025-06-28 21:53:47 +00:00
feat(issue-41): set and inherit labels (#48)
fix https://github.com/kiegroup/git-backporting/issues/41
This commit is contained in:
parent
f923f7f4c2
commit
fcc01673f4
28 changed files with 962 additions and 140 deletions
|
@ -19,4 +19,32 @@ export function parseArgs(configFileContent: string): Args {
|
|||
export function readConfigFile(pathToFile: string): Args {
|
||||
const asString: string = fs.readFileSync(pathToFile, "utf-8");
|
||||
return parseArgs(asString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the input only if it is not a blank or null string, otherwise returns undefined
|
||||
* @param key input key
|
||||
* @returns the value or undefined
|
||||
*/
|
||||
export function getOrUndefined(value: string): string | undefined {
|
||||
return value !== "" ? value : undefined;
|
||||
}
|
||||
|
||||
// get rid of inner spaces too
|
||||
export function getAsCleanedCommaSeparatedList(value: string): string[] | undefined {
|
||||
// trim the value
|
||||
const trimmed: string = value.trim();
|
||||
return trimmed !== "" ? trimmed.replace(/\s/g, "").split(",") : undefined;
|
||||
}
|
||||
|
||||
// preserve inner spaces
|
||||
export function getAsCommaSeparatedList(value: string): string[] | undefined {
|
||||
// trim the value
|
||||
const trimmed: string = value.trim();
|
||||
return trimmed !== "" ? trimmed.split(",").map(v => v.trim()) : undefined;
|
||||
}
|
||||
|
||||
export function getAsBooleanOrDefault(value: string): boolean | undefined {
|
||||
const trimmed = value.trim();
|
||||
return trimmed !== "" ? trimmed.toLowerCase() === "true" : undefined;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue