mirror of
https://github.com/actions/labeler.git
synced 2025-12-11 12:07:32 +00:00
Improved Error message for missing config file (#475)
* error message for missing config * chore: formatting and index js * chore: update json5 * changes from cr Co-authored-by: AndreiLobanovich <andreilobanovich@github.com> * chore: recreate dist.js * chore: revert package-lock * chore: newline fix --------- Co-authored-by: AndreiLobanovich <andreilobanovich@github.com>
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
node_modules/
|
node_modules/
|
||||||
lib/
|
lib/
|
||||||
|
.idea
|
||||||
11
dist/index.js
vendored
11
dist/index.js
vendored
@@ -138,7 +138,16 @@ function getChangedFiles(client, prNumber) {
|
|||||||
}
|
}
|
||||||
function getLabelGlobs(client, configurationPath) {
|
function getLabelGlobs(client, configurationPath) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const configurationContent = yield fetchContent(client, configurationPath);
|
let configurationContent;
|
||||||
|
try {
|
||||||
|
configurationContent = yield fetchContent(client, configurationPath);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
if (e.name == 'HttpError' || e.name == 'NotFound') {
|
||||||
|
core.warning(`The config file was not found at ${configurationPath}. Make sure it exists and that this action has the correct access rights.`);
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
// loads (hopefully) a `{[label:string]: string | StringOrMatchConfig[]}`, but is `any`:
|
// loads (hopefully) a `{[label:string]: string | StringOrMatchConfig[]}`, but is `any`:
|
||||||
const configObject = yaml.load(configurationContent);
|
const configObject = yaml.load(configurationContent);
|
||||||
// transform `any` => `Map<string,StringOrMatchConfig[]>` or throw if yaml is malformed:
|
// transform `any` => `Map<string,StringOrMatchConfig[]>` or throw if yaml is malformed:
|
||||||
|
|||||||
@@ -133,10 +133,17 @@ async function getLabelGlobs(
|
|||||||
client: ClientType,
|
client: ClientType,
|
||||||
configurationPath: string
|
configurationPath: string
|
||||||
): Promise<Map<string, StringOrMatchConfig[]>> {
|
): Promise<Map<string, StringOrMatchConfig[]>> {
|
||||||
const configurationContent: string = await fetchContent(
|
let configurationContent: string;
|
||||||
client,
|
try {
|
||||||
configurationPath
|
configurationContent = await fetchContent(client, configurationPath);
|
||||||
);
|
} catch (e: any) {
|
||||||
|
if (e.name == 'HttpError' || e.name == 'NotFound') {
|
||||||
|
core.warning(
|
||||||
|
`The config file was not found at ${configurationPath}. Make sure it exists and that this action has the correct access rights.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
// loads (hopefully) a `{[label:string]: string | StringOrMatchConfig[]}`, but is `any`:
|
// loads (hopefully) a `{[label:string]: string | StringOrMatchConfig[]}`, but is `any`:
|
||||||
const configObject: any = yaml.load(configurationContent);
|
const configObject: any = yaml.load(configurationContent);
|
||||||
|
|||||||
Reference in New Issue
Block a user