Skip to content

Commit 55466e2

Browse files
committed
BREAKING: Error out if to or from options is passed in config
1 parent 3905396 commit 55466e2

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,12 @@ function rc (ctx, path) {
214214
if (argv.use) return Promise.resolve()
215215

216216
return postcssrc(ctx, path)
217-
.then((rc) => { config = rc })
217+
.then((rc) => {
218+
if (rc.options.from || rc.options.to) {
219+
error('Config Error: Can not set from or to options in config file, use CLI arguments instead')
220+
}
221+
config = rc
222+
})
218223
.catch((err) => {
219224
if (err.message.indexOf('No PostCSS Config found') === -1) throw err
220225
})

test/config.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,33 @@ test("doesn't error on empty config", async function (t) {
4545
await read('test/fixtures/a.css')
4646
)
4747
})
48+
49+
test('errors if `to` is set', async function (t) {
50+
const env = `module.exports = {
51+
to: 'out.css'
52+
}`
53+
54+
const dir = await ENV(env, ['a.css'])
55+
56+
const { stderr } = await cli(
57+
['a.css', '-o', 'output.css', '--no-map'],
58+
dir
59+
)
60+
61+
t.regex(stderr, /Config Error: Can not set from or to options in config file, use CLI arguments instead/)
62+
})
63+
64+
test('errors if `from` is set', async function (t) {
65+
const env = `module.exports = {
66+
from: 'in.css'
67+
}`
68+
69+
const dir = await ENV(env, ['a.css'])
70+
71+
const { stderr } = await cli(
72+
['a.css', '-o', 'output.css', '--no-map'],
73+
dir
74+
)
75+
76+
t.regex(stderr, /Config Error: Can not set from or to options in config file, use CLI arguments instead/)
77+
})

0 commit comments

Comments
 (0)