Merge pull request #148 from mikepenz/feature/147_2
Differentiate log between config missing or config invalid
This commit is contained in:
+11
-6
@@ -333,7 +333,7 @@ function run() {
|
|||||||
core.setOutput('changelog', result);
|
core.setOutput('changelog', result);
|
||||||
// write the result in changelog to file if possible
|
// write the result in changelog to file if possible
|
||||||
const outputFile = core.getInput('outputFile');
|
const outputFile = core.getInput('outputFile');
|
||||||
if (outputFile !== "") {
|
if (outputFile !== '') {
|
||||||
core.debug(`Enabled writing the changelog to disk`);
|
core.debug(`Enabled writing the changelog to disk`);
|
||||||
utils_1.writeOutput(repositoryPath, outputFile, result);
|
utils_1.writeOutput(repositoryPath, outputFile, result);
|
||||||
}
|
}
|
||||||
@@ -1231,10 +1231,7 @@ function resolveConfiguration(githubWorkspacePath, configurationFile) {
|
|||||||
const configurationPath = path.resolve(githubWorkspacePath, configurationFile);
|
const configurationPath = path.resolve(githubWorkspacePath, configurationFile);
|
||||||
core.debug(`configurationPath = '${configurationPath}'`);
|
core.debug(`configurationPath = '${configurationPath}'`);
|
||||||
const providedConfiguration = readConfiguration(configurationPath);
|
const providedConfiguration = readConfiguration(configurationPath);
|
||||||
if (!providedConfiguration) {
|
if (providedConfiguration) {
|
||||||
core.info(`⚠️ Configuration provided, but it couldn't be found, or failed to parse. Fallback to Defaults`);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
configuration = providedConfiguration;
|
configuration = providedConfiguration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1245,12 +1242,20 @@ exports.resolveConfiguration = resolveConfiguration;
|
|||||||
* Reads in the configuration from the JSON file
|
* Reads in the configuration from the JSON file
|
||||||
*/
|
*/
|
||||||
function readConfiguration(filename) {
|
function readConfiguration(filename) {
|
||||||
|
let rawdata;
|
||||||
|
try {
|
||||||
|
rawdata = fs.readFileSync(filename, 'utf8');
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
core.info(`⚠️ Configuration provided, but it couldn't be found. Fallback to Defaults.`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const rawdata = fs.readFileSync(filename, 'utf8');
|
|
||||||
const configurationJSON = JSON.parse(rawdata);
|
const configurationJSON = JSON.parse(rawdata);
|
||||||
return configurationJSON;
|
return configurationJSON;
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
core.info(`⚠️ Configuration provided, but it couldn't be parsed. Fallback to Defaults.`);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
+10664
-1
File diff suppressed because it is too large
Load Diff
+13
-6
@@ -51,11 +51,7 @@ export function resolveConfiguration(
|
|||||||
)
|
)
|
||||||
core.debug(`configurationPath = '${configurationPath}'`)
|
core.debug(`configurationPath = '${configurationPath}'`)
|
||||||
const providedConfiguration = readConfiguration(configurationPath)
|
const providedConfiguration = readConfiguration(configurationPath)
|
||||||
if (!providedConfiguration) {
|
if (providedConfiguration) {
|
||||||
core.info(
|
|
||||||
`⚠️ Configuration provided, but it couldn't be found, or failed to parse. Fallback to Defaults`
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
configuration = providedConfiguration
|
configuration = providedConfiguration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,11 +62,22 @@ export function resolveConfiguration(
|
|||||||
* Reads in the configuration from the JSON file
|
* Reads in the configuration from the JSON file
|
||||||
*/
|
*/
|
||||||
function readConfiguration(filename: string): Configuration | null {
|
function readConfiguration(filename: string): Configuration | null {
|
||||||
|
let rawdata: string
|
||||||
|
try {
|
||||||
|
rawdata = fs.readFileSync(filename, 'utf8')
|
||||||
|
} catch (error) {
|
||||||
|
core.info(
|
||||||
|
`⚠️ Configuration provided, but it couldn't be found. Fallback to Defaults.`
|
||||||
|
)
|
||||||
|
return null
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const rawdata = fs.readFileSync(filename, 'utf8')
|
|
||||||
const configurationJSON: Configuration = JSON.parse(rawdata)
|
const configurationJSON: Configuration = JSON.parse(rawdata)
|
||||||
return configurationJSON
|
return configurationJSON
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
core.info(
|
||||||
|
`⚠️ Configuration provided, but it couldn't be parsed. Fallback to Defaults.`
|
||||||
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user