diff --git a/test/config.js b/test/config.js index 7666b83..bb32d97 100644 --- a/test/config.js +++ b/test/config.js @@ -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 = { @@ -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, ) @@ -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, ) @@ -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')) +}) diff --git a/test/fixtures/cfg-dir/postcss.config.js b/test/fixtures/cfg-dir/postcss.config.js new file mode 100644 index 0000000..e9c454b --- /dev/null +++ b/test/fixtures/cfg-dir/postcss.config.js @@ -0,0 +1,6 @@ +import postcssImport from 'postcss-import' +export default function () { + return { + plugins: [postcssImport()], + } +}