Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions test/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ENV from './helpers/env.js'

import cli from './helpers/cli.js'
import read from './helpers/read.js'
import tmp from './helpers/tmp.js'

test('supports common config', async (t) => {
const env = `module.exports = {
Expand All @@ -13,10 +14,10 @@ test('supports common config', async (t) => {
]
}`

const dir = await ENV(env, ['a.css'])
const dir = await ENV(env, ['import.css', 'a.css'])

const { error, stderr } = await cli(
['a.css', '-o', 'output.css', '--no-map'],
['import.css', '-o', 'output.css', '--no-map'],
dir,
)

Expand All @@ -38,10 +39,10 @@ test('supports ESM config', async (t) => {
}
}`

const dir = await ENV(env, ['a.css'], 'mjs')
const dir = await ENV(env, ['import.css', 'a.css'], 'mjs')

const { error, stderr } = await cli(
['a.css', '-o', 'output.css', '--no-map'],
['import.css', '-o', 'output.css', '--no-map'],
dir,
)

Expand Down Expand Up @@ -100,3 +101,20 @@ test('errors if `from` is set', async (t) => {
/Config Error: Can not set from or to options in config file, use CLI arguments instead/,
)
})

test('supports --config flag', async (t) => {
const output = tmp('output.css')

const { error, stderr } = await cli([
'test/fixtures/import.css',
'-o',
output,
'--no-map',
'--config',
'test/fixtures/cfg-dir',
])

t.falsy(error, stderr)

t.is(await read(output), await read('test/fixtures/a.css'))
})
6 changes: 6 additions & 0 deletions test/fixtures/cfg-dir/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import postcssImport from 'postcss-import'
export default function () {
return {
plugins: [postcssImport()],
}
}