Skip to content

Commit

Permalink
fix: handle absolute config paths correctly #647
Browse files Browse the repository at this point in the history
  • Loading branch information
marionebl committed May 9, 2019
1 parent ec3da92 commit 49b3a77
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion @commitlint/load/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default async (seed = {}, options = {cwd: process.cwd()}) => {
async function loadConfig(cwd, configPath) {
const explorer = cosmiconfig('commitlint');

const explicitPath = configPath ? path.join(cwd, configPath) : undefined;
const explicitPath = configPath ? path.resolve(cwd, configPath) : undefined;
const explore = explicitPath ? explorer.load : explorer.search;
const searchPath = explicitPath ? explicitPath : cwd;
const local = await explore(searchPath);
Expand Down
9 changes: 8 additions & 1 deletion @commitlint/load/src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,20 @@ test('uses seed as configured', async t => {
t.is(actual.rules.foo, 'bar');
});

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

test('rules should be loaded from absolute config file', async t => {
const cwd = await git.bootstrap('fixtures/specify-config-file');
const file = path.join(cwd, 'config/commitlint.config.js');
const actual = await load({}, {cwd: process.cwd(), file});
t.is(actual.rules.foo, 'bar');
});

test('plugins should be loaded from seed', async t => {
const plugin = {'@global': true};
const scopedPlugin = {'@global': true};
Expand Down

0 comments on commit 49b3a77

Please sign in to comment.