From 3a676528c53d46b055622dd6d75c9058c66bb3bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=BA?= Date: Sat, 14 Apr 2018 14:31:29 +0800 Subject: [PATCH] automatically switch syntax --- index.js | 4 ++++ package.json | 1 + test/syntax.js | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) 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')) +})