Skip to content

Commit

Permalink
Fix --syntax, --parser, & --stringifier options; add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanZim committed Jan 11, 2017
1 parent 4ee90f3 commit fc51574
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Expand Up @@ -52,9 +52,9 @@ let input = argv._ || argv.input
let output = argv.output

const defaultOptions = {
parser: argv.parser,
syntax: argv.syntax,
strigifier: argv.strigifier,
parser: argv.parser ? require(argv.parser) : undefined,
syntax: argv.syntax ? require(argv.syntax) : undefined,
stringifier: argv.stringifier ? require(argv.stringifier) : undefined,
map: argv.map
}

Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -41,6 +41,7 @@
"nyc": "^10.0.0",
"postcss-import": "^9.0.0",
"standard": "^8.4.0",
"sugarss": "^0.2.0",
"uuid": "^3.0.1"
}
}
3 changes: 3 additions & 0 deletions test/fixtures/sugar-white.css
@@ -0,0 +1,3 @@
.sugar {
color: white
}
2 changes: 2 additions & 0 deletions test/fixtures/sugar-white.sss
@@ -0,0 +1,2 @@
.sugar
color: white
21 changes: 21 additions & 0 deletions test/postcss-cli.js
Expand Up @@ -18,3 +18,24 @@ test('--dir works', async function (t) {
t.is(await read(path.join(outDir, 'a-red.css')), await read('test/fixtures/a-red.css'))
t.is(await read(path.join(outDir, 'a-blue.css')), await read('test/fixtures/a-blue.css'))
})

test('--parser works', async function (t) {
var out = tmp('.css')
var { error } = await run(['test/fixtures/sugar-white.sss', '--parser', 'sugarss', '-o', out])
t.ifError(error)
t.is(await read(out), await read('test/fixtures/sugar-white.css'))
})

test('--stringifier works', async function (t) {
var out = tmp('.css')
var { error } = await run(['test/fixtures/sugar-white.css', '--stringifier', 'sugarss', '-o', out])
t.ifError(error)
t.is(await read(out), await read('test/fixtures/sugar-white.sss'))
})

test('--syntax works', async function (t) {
var out = tmp('.css')
var { error } = await run(['test/fixtures/sugar-white.sss', '--syntax', 'sugarss', '-o', out])
t.ifError(error)
t.is(await read(out), await read('test/fixtures/sugar-white.sss'))
})

0 comments on commit fc51574

Please sign in to comment.