diff --git a/index.js b/index.js index e1791a9..7827409 100644 --- a/index.js +++ b/index.js @@ -206,6 +206,10 @@ function css(css, file) { ) } + if (!options.parser && !options.syntax && !options.stringifier) { + options.syntax = require('postcss-syntax') + } + return postcss(config.plugins) .process(css, options) .then(result => { diff --git a/package.json b/package.json index 2f5f8cb..5c8df49 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "postcss": "^6.0.1", "postcss-load-config": "^1.1.0", "postcss-reporter": "^5.0.0", + "postcss-syntax": "^0.1.0", "pretty-hrtime": "^1.0.3", "read-cache": "^1.0.0", "yargs": "^11.0.0" diff --git a/test/syntax.js b/test/syntax.js index 39877d8..a73f554 100644 --- a/test/syntax.js +++ b/test/syntax.js @@ -20,3 +20,19 @@ test('--syntax works', async t => { t.is(await read(output), await read('test/fixtures/a.sss')) }) + +test('automatically switch syntax', async t => { + const dir = tmp() + + const { error, stderr } = await cli([ + 'test/fixtures/b.*', + '-d', + dir, + '--no-map' + ]) + + t.ifError(error, stderr) + + t.is(await read(`${dir}/b.sss`), await read('test/fixtures/b.sss')) + t.is(await read(`${dir}/b.css`), await read('test/fixtures/b.css')) +})