Skip to content

Commit

Permalink
Merge pull request #2387 from jBouyoud/fix-config-extends
Browse files Browse the repository at this point in the history
fix(core): fix configuration extends overrides order
  • Loading branch information
hipstersmoothie committed Sep 6, 2023
2 parents 6d4d083 + 5cb1b69 commit 97ed2c3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
10 changes: 6 additions & 4 deletions packages/core/src/__tests__/__snapshots__/auto.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ exports[`Auto createLabels should create the labels 1`] = `
}
`;

exports[`Auto should extend config 1`] = `
exports[`Auto should extend config and keep overrides 1`] = `
Object {
"baseBranch": "main",
"extends": "@artsy/auto-config/package.json",
"extends": "@artsy",
"labels": Array [
Object {
"changelogTitle": "💥 Breaking Change",
Expand Down Expand Up @@ -156,6 +156,7 @@ Object {
"releaseType": "patch",
},
],
"name": "extended",
"onlyPublishWithReleaseLabel": true,
"owner": "foo",
"plugins": Array [
Expand All @@ -169,10 +170,10 @@ Object {
}
`;

exports[`Auto should extend local config 1`] = `
exports[`Auto should extend local config and keep overrides 1`] = `
Object {
"baseBranch": "main",
"extends": "<PROJECT_ROOT>fake.json",
"extends": "./fake.json",
"labels": Array [
Object {
"changelogTitle": "💥 Breaking Change",
Expand Down Expand Up @@ -243,6 +244,7 @@ Object {
"releaseType": "patch",
},
],
"name": "extended",
"noVersionPrefix": true,
"owner": "foo",
"plugins": Array [
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/__tests__/auto.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ describe("Auto", () => {
process.env.GH_TOKEN = "XXXX";
});

test("should extend config", async () => {
search.mockReturnValueOnce({ config: { ...defaults, extends: "@artsy" } });
test("should extend config and keep overrides", async () => {
search.mockReturnValueOnce({ config: { ...defaults, extends: "@artsy", name: 'extended' } });
importMock.mockImplementation((path) =>
path === "@artsy/auto-config/package.json"
? { auto: { onlyPublishWithReleaseLabel: true } }
? { auto: { onlyPublishWithReleaseLabel: true }, name: '@artsy' }
: undefined
);

Expand All @@ -204,14 +204,14 @@ describe("Auto", () => {
expect(process.exit).toHaveBeenCalled();
});

test("should extend local config", async () => {
test("should extend local config and keep overrides", async () => {
const orig = process.cwd;
process.cwd = () => "/foo/";
search.mockReturnValueOnce({
config: { ...defaults, extends: "./fake.json" },
config: { ...defaults, extends: "./fake.json", name: 'extended' },
});
importMock.mockImplementation((path) =>
path === "/foo/fake.json" ? { noVersionPrefix: true } : undefined
path === "/foo/fake.json" ? { noVersionPrefix: true, name: 'fake' } : undefined
);

const auto = new Auto();
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ export default class Config {

if (rawConfig.extends) {
rawConfig = merge(
rawConfig,
await this.loadExtendConfig(rawConfig.extends)
await this.loadExtendConfig(rawConfig.extends),
rawConfig
);
}

Expand Down

0 comments on commit 97ed2c3

Please sign in to comment.