-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathconfig.js
77 lines (57 loc) · 1.58 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import test from 'ava'
import path from 'path'
import ENV from './helpers/env.js'
import cli from './helpers/cli.js'
import read from './helpers/read.js'
test('supports common config', async (t) => {
const env = `module.exports = {
plugins: [
require('postcss-import')()
]
}`
const dir = await ENV(env, ['a.css'])
const { error, stderr } = await cli(
['a.css', '-o', 'output.css', '--no-map'],
dir
)
t.falsy(error, stderr)
t.is(
await read(path.join(dir, 'output.css')),
await read('test/fixtures/a.css')
)
})
test("doesn't error on empty config", async (t) => {
const env = `module.exports = {}`
const dir = await ENV(env, ['a.css'])
const { error, stderr } = await cli(
['a.css', '-o', 'output.css', '--no-map'],
dir
)
t.falsy(error, stderr)
t.is(
await read(path.join(dir, 'output.css')),
await read('test/fixtures/a.css')
)
})
test('errors if `to` is set', async (t) => {
const env = `module.exports = {
to: 'out.css'
}`
const dir = await ENV(env, ['a.css'])
const { stderr } = await cli(['a.css', '-o', 'output.css', '--no-map'], dir)
t.regex(
stderr,
/Config Error: Can not set from or to options in config file, use CLI arguments instead/
)
})
test('errors if `from` is set', async (t) => {
const env = `module.exports = {
from: 'in.css'
}`
const dir = await ENV(env, ['a.css'])
const { stderr } = await cli(['a.css', '-o', 'output.css', '--no-map'], dir)
t.regex(
stderr,
/Config Error: Can not set from or to options in config file, use CLI arguments instead/
)
})