Skip to content

Commit dc49321

Browse files
committed
fix empty object foreach
1 parent 0b48d69 commit dc49321

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

Diff for: .res/labels.merge3.yml

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

Diff for: __tests__/labeler.test.ts

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

Diff for: dist/index.js

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/labeler.ts

+2-1
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)