Skip to content

Commit

Permalink
automatically switch syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
gucong3000 committed Apr 14, 2018
1 parent 74119f4 commit 3a67652
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 16 additions & 0 deletions test/syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
})

0 comments on commit 3a67652

Please sign in to comment.