Skip to content

Commit c6f50d5

Browse files
committed
test: override config file options via CLI args, issue #304
1 parent 5b41e62 commit c6f50d5

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

test/config/.config-input-priority

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
'input': 'src/**/*.html'
3+
}

test/test-cfg-resolve.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ test('should return config with one use key with one property', async t => {
3030

3131
test('should return config with key config', async t => {
3232
const flags = {
33-
config: 'test/config/.config'
33+
config: 'test/config/.config-plugins'
3434
};
3535
const config = await cfgResolve({flags});
3636
const expected = {'posthtml-bem': {}};
@@ -41,11 +41,27 @@ test('should return config with key config', async t => {
4141
test('should return config with key config and use key', async t => {
4242
const flags = {
4343
use: 'posthtml-assets',
44-
config: 'test/config/.config'
44+
config: 'test/config/.config-plugins'
4545
};
4646
const config = await cfgResolve({flags});
4747
const expected = {'posthtml-bem': {}, 'posthtml-assets': {}};
4848

4949
t.deepEqual(config.plugins, expected);
5050
});
5151

52+
test('should return config when CLI params priority', async t => {
53+
const input = {input: 'src/template/**/*.html'};
54+
const flags = {
55+
config: 'test/config/.config-input-priority'
56+
};
57+
const config = await cfgResolve({input, flags});
58+
const expected = {
59+
allInOutput: undefined,
60+
input: 'src/template/**/*.html',
61+
output: undefined,
62+
root: './'
63+
};
64+
65+
t.deepEqual(config, expected);
66+
});
67+

0 commit comments

Comments
 (0)