diff --git a/.res/labels.merge3.yml b/.res/labels.merge3.yml new file mode 100644 index 00000000..ed1b4adb --- /dev/null +++ b/.res/labels.merge3.yml @@ -0,0 +1 @@ +_extends: ghaction-github-labeler:.res/labels.merge1.yml diff --git a/__tests__/labeler.test.ts b/__tests__/labeler.test.ts index 64e8f684..d7b73bb2 100644 --- a/__tests__/labeler.test.ts +++ b/__tests__/labeler.test.ts @@ -174,4 +174,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 = { + 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(); + }); }); diff --git a/dist/index.js b/dist/index.js index cbb8fc96..5b137141 100644 --- a/dist/index.js +++ b/dist/index.js @@ -276,7 +276,9 @@ class Labeler { const output = []; 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 => { diff --git a/src/labeler.ts b/src/labeler.ts index 9394c473..57723970 100644 --- a/src/labeler.ts +++ b/src/labeler.ts @@ -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 => {