Skip to content

Commit 88ff080

Browse files
committed
automatically switch syntax
1 parent 3ec9b6e commit 88ff080

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

index.js

+4
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ function css(css, file) {
206206
)
207207
}
208208

209+
if (!options.parser && !options.syntax && !options.stringifier) {
210+
options.syntax = require('postcss-syntax')
211+
}
212+
209213
return postcss(config.plugins)
210214
.process(css, options)
211215
.then(result => {

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"postcss": "^7.0.0",
2828
"postcss-load-config": "^2.0.0",
2929
"postcss-reporter": "^5.0.0",
30+
"postcss-syntax": "^0.32.0",
3031
"pretty-hrtime": "^1.0.3",
3132
"read-cache": "^1.0.0",
3233
"yargs": "^12.0.1"

test/syntax.js

+16
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,19 @@ test('--syntax works', async t => {
2020

2121
t.is(await read(output), await read('test/fixtures/a.sss'))
2222
})
23+
24+
test('automatically switch syntax', async t => {
25+
const dir = tmp()
26+
27+
const { error, stderr } = await cli([
28+
'test/fixtures/b.*',
29+
'-d',
30+
dir,
31+
'--no-map'
32+
])
33+
34+
t.ifError(error, stderr)
35+
36+
t.is(await read(`${dir}/b.sss`), await read('test/fixtures/b.sss'))
37+
t.is(await read(`${dir}/b.css`), await read('test/fixtures/b.css'))
38+
})

0 commit comments

Comments
 (0)