Skip to content

Commit 85e00ba

Browse files
committed
fix empty object foreach
1 parent 300306f commit 85e00ba

File tree

5 files changed

+28
-3
lines changed

5 files changed

+28
-3
lines changed

.res/labels.merge3.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_extends: ghaction-github-labeler:.res/labels.merge1.yml

__tests__/labeler.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,27 @@ describe('run', () => {
173173
expect(fileLabels[1]).toEqual(expect.objectContaining({name: ':bug: bug', description: 'Damn bugs'}));
174174
expect(() => labeler.run()).not.toThrow();
175175
});
176+
it('extends', async () => {
177+
const input = <Inputs>{
178+
githubToken: process.env.GITHUB_TOKEN || 'test',
179+
yamlFile: '.res/labels.merge3.yml',
180+
skipDelete: true,
181+
dryRun: true,
182+
exclude: []
183+
};
184+
nock('https://api.github.com').get('/repos/crazy-max/ghaction-github-labeler/labels').reply(200, labelsFixture());
185+
186+
nock('https://api.github.com')
187+
.get(`/repos/crazy-max/ghaction-github-labeler/contents/${encodeURIComponent(input.yamlFile as string)}`)
188+
.reply(200, configFixture(input.yamlFile as string));
189+
190+
nock('https://api.github.com')
191+
.get(`/repos/crazy-max/ghaction-github-labeler/contents/${encodeURIComponent('.res/labels.merge1.yml')}`)
192+
.reply(200, configFixture('.res/labels.merge1.yml'));
193+
194+
const labeler = new Labeler(input);
195+
const fileLabels = await labeler.fileLabels;
196+
expect(fileLabels.length).toBe(15);
197+
expect(() => labeler.run()).not.toThrow();
198+
});
176199
});

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/labeler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ export class Labeler {
211211
const output = [] as Label[];
212212
configs
213213
.map(config => {
214-
const labels = config.labels ? config.labels : config;
214+
let labels = config.labels ? config.labels : config;
215+
if (Object.keys(labels).length === 0) labels = undefined;
215216
return {labels: labels || []};
216217
})
217218
.map(config => {

0 commit comments

Comments
 (0)