mirror of
https://github.com/kiegroup/git-backporting.git
synced 2025-06-28 21:53:47 +00:00
feat: config file as option (#42)
Fix https://github.com/lampajr/backporting/issues/37 This enhancement required a huge refactoring where all arguments defaults have been centralized in one single place ArgsParser#parse
This commit is contained in:
parent
a88adeec35
commit
5ead31f606
27 changed files with 1465 additions and 219 deletions
22
src/service/args/args-utils.ts
Normal file
22
src/service/args/args-utils.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
import { Args } from "@bp/service/args/args.types";
|
||||
import * as fs from "fs";
|
||||
|
||||
/**
|
||||
* Parse the input configuation string as json object and
|
||||
* return it as Args
|
||||
* @param configFileContent
|
||||
* @returns {Args}
|
||||
*/
|
||||
export function parseArgs(configFileContent: string): Args {
|
||||
return JSON.parse(configFileContent) as Args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a configuration file in json format anf parse it as {Args}
|
||||
* @param pathToFile Full path name of the config file, e.g., /tmp/dir/config-file.json
|
||||
* @returns {Args}
|
||||
*/
|
||||
export function readConfigFile(pathToFile: string): Args {
|
||||
const asString: string = fs.readFileSync(pathToFile, "utf-8");
|
||||
return parseArgs(asString);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue