Skip to content

Commit 49b3a77

Browse files
committed
fix: handle absolute config paths correctly #647
1 parent ec3da92 commit 49b3a77

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

@commitlint/load/src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export default async (seed = {}, options = {cwd: process.cwd()}) => {
106106
async function loadConfig(cwd, configPath) {
107107
const explorer = cosmiconfig('commitlint');
108108

109-
const explicitPath = configPath ? path.join(cwd, configPath) : undefined;
109+
const explicitPath = configPath ? path.resolve(cwd, configPath) : undefined;
110110
const explore = explicitPath ? explorer.load : explorer.search;
111111
const searchPath = explicitPath ? explicitPath : cwd;
112112
const local = await explore(searchPath);

@commitlint/load/src/index.test.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,20 @@ test('uses seed as configured', async t => {
2121
t.is(actual.rules.foo, 'bar');
2222
});
2323

24-
test('rules should be loaded from specify config file', async t => {
24+
test('rules should be loaded from relative config file', async t => {
2525
const file = 'config/commitlint.config.js';
2626
const cwd = await git.bootstrap('fixtures/specify-config-file');
2727
const actual = await load({}, {cwd, file});
2828
t.is(actual.rules.foo, 'bar');
2929
});
3030

31+
test('rules should be loaded from absolute config file', async t => {
32+
const cwd = await git.bootstrap('fixtures/specify-config-file');
33+
const file = path.join(cwd, 'config/commitlint.config.js');
34+
const actual = await load({}, {cwd: process.cwd(), file});
35+
t.is(actual.rules.foo, 'bar');
36+
});
37+
3138
test('plugins should be loaded from seed', async t => {
3239
const plugin = {'@global': true};
3340
const scopedPlugin = {'@global': true};

0 commit comments

Comments
 (0)