Skip to content

Commit

Permalink
fix empty object foreach
Browse files Browse the repository at this point in the history
  • Loading branch information
jetersen committed Jul 27, 2022
1 parent 300306f commit 85e00ba
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions .res/labels.merge3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_extends: ghaction-github-labeler:.res/labels.merge1.yml
23 changes: 23 additions & 0 deletions __tests__/labeler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,27 @@ describe('run', () => {
expect(fileLabels[1]).toEqual(expect.objectContaining({name: ':bug: bug', description: 'Damn bugs'}));
expect(() => labeler.run()).not.toThrow();
});
it('extends', async () => {
const input = <Inputs>{
githubToken: process.env.GITHUB_TOKEN || 'test',
yamlFile: '.res/labels.merge3.yml',
skipDelete: true,
dryRun: true,
exclude: []
};
nock('https://api.github.com').get('/repos/crazy-max/ghaction-github-labeler/labels').reply(200, labelsFixture());

nock('https://api.github.com')
.get(`/repos/crazy-max/ghaction-github-labeler/contents/${encodeURIComponent(input.yamlFile as string)}`)
.reply(200, configFixture(input.yamlFile as string));

nock('https://api.github.com')
.get(`/repos/crazy-max/ghaction-github-labeler/contents/${encodeURIComponent('.res/labels.merge1.yml')}`)
.reply(200, configFixture('.res/labels.merge1.yml'));

const labeler = new Labeler(input);
const fileLabels = await labeler.fileLabels;
expect(fileLabels.length).toBe(15);
expect(() => labeler.run()).not.toThrow();
});
});
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/labeler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ export class Labeler {
const output = [] as Label[];
configs
.map(config => {
const labels = config.labels ? config.labels : config;
let labels = config.labels ? config.labels : config;
if (Object.keys(labels).length === 0) labels = undefined;
return {labels: labels || []};
})
.map(config => {
Expand Down

0 comments on commit 85e00ba

Please sign in to comment.