Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

Commit 04f76a4

Browse files
committed
Added: --browsers CLI option
Close #66
1 parent 62dd6cf commit 04f76a4

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Unreleased
22

33
- Added: `--config` CLI option
4+
- Added: `--browsers`CLI option
45

56
# 1.0.1 - 2015-02-18
67

bin/cssnext.js

100644100755
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ program
1818
.version(pkg.version)
1919
.usage("[options] [<input> [<output>]]")
2020
.option("-C, --config <file>", "use the config file")
21+
.option("-b, --browsers <items>", "browsers list (comma separated)")
2122
.option("-I, --no-import", "do not inline @import")
2223
.option("-U, --no-url", "do not adjust url()")
2324
.option("-c, --compress", "compress output")
@@ -61,15 +62,11 @@ if (!config.features) {
6162
}
6263
// command line flags override config file
6364
Object.keys(cssnext.features).forEach(function(feature) {
64-
if (typeof config.features[feature] === "object") {
65-
if (program[feature] === false) {
66-
config.features[feature] = false
67-
}
68-
}
69-
else {
70-
config.features[feature] = program[feature]
65+
if (program[feature] === false) {
66+
config.features[feature] = false
7167
}
7268
})
69+
if ("browsers" in program) { config.browsers = program.browsers }
7370
if ("import" in program) { config.import = program.import }
7471
if ("url" in program) { config.url = program.url }
7572
if ("sourcemap" in program) { config.sourcemap = program.sourcemap }

test/cli.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ test("cli", function(t) {
6060
})
6161
planned+=1
6262

63+
var noCustomPropInput = ":root{--foo:bar}baz{qux:var(--foo)}"
64+
var childProcessBrowsers = exec(cssnextBin + " --browsers \"Firefox >= 31\"", function(err, stdout) {
65+
if (err) { throw err }
66+
t.equal(stdout, noCustomPropInput, "should have a --browsers option")
67+
})
68+
childProcessBrowsers.stdin.write(new Buffer(noCustomPropInput))
69+
childProcessBrowsers.stdin.end()
70+
planned+=1
71+
6372
exec(cssnextBin + " --verbose test/fixtures/cli.css test/fixtures/cli.output--verbose.css", function(err, stdout) {
6473
if (err) { throw err }
6574
t.ok(utils.contains(stdout, "Output written"), "should log on --verbose")

0 commit comments

Comments
 (0)