- introduce capability to define the Configuration via the build yml without the requirement of a file
- this also allows to generate changelogs without the need to chech-out
This commit is contained in:
+17
-9
@@ -67,24 +67,32 @@ export function resolveConfiguration(
|
||||
/**
|
||||
* Reads in the configuration from the JSON file
|
||||
*/
|
||||
function readConfiguration(filename: string): Configuration | null {
|
||||
let rawdata: string
|
||||
function readConfiguration(filename: string): Configuration | undefined {
|
||||
try {
|
||||
rawdata = fs.readFileSync(filename, 'utf8')
|
||||
const rawdata = fs.readFileSync(filename, 'utf8')
|
||||
if (rawdata) {
|
||||
return parseConfiguration(rawdata)
|
||||
}
|
||||
} catch (error) {
|
||||
core.info(
|
||||
`⚠️ Configuration provided, but it couldn't be found. Fallback to Defaults.`
|
||||
)
|
||||
return null
|
||||
core.debug(`Failed to load configuration due to: ${error}`)
|
||||
}
|
||||
core.info(
|
||||
`⚠️ Configuration provided, but it couldn't be found. Fallback to Defaults.`
|
||||
)
|
||||
return undefined
|
||||
}
|
||||
/**
|
||||
* Parses the configuration from the JSON file
|
||||
*/
|
||||
export function parseConfiguration(config: string): Configuration | undefined {
|
||||
try {
|
||||
const configurationJSON: Configuration = JSON.parse(rawdata)
|
||||
const configurationJSON: Configuration = JSON.parse(config)
|
||||
return configurationJSON
|
||||
} catch (error) {
|
||||
core.info(
|
||||
`⚠️ Configuration provided, but it couldn't be parsed. Fallback to Defaults.`
|
||||
)
|
||||
return null
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user