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

Commit ab51614

Browse files
committed
Fixed: CLI now add to option automatically + Added: CLI output file dirname is now automatically created
Close #159 Close #146
1 parent 065d327 commit ab51614

File tree

6 files changed

+34
-0
lines changed

6 files changed

+34
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11

22
- Fixed: replacement of `postcss-log-warnings` (deprecated) by `postcss-reporter`
33
([#162](https://github.com/cssnext/cssnext/issues/162))
4+
- Fixed: CLI now add `to` option automatically
5+
([#159](https://github.com/cssnext/cssnext/issues/159))
6+
If you were happy with the previous CLI behavior (which was not rebasing url), you should probably just add the `--no-url` to keep the CSS as it was.
7+
- Added: CLI output file dirname is now automatically created (using `mkdirp`)
8+
([#146](https://github.com/cssnext/cssnext/issues/146))
49

510
# 1.7.1 - 2015-06-19
611

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"commander": "^2.3.0",
3333
"cssnano": "^2.0.1",
3434
"exit": "^0.1.2",
35+
"mkdirp": "^0.5.1",
3536
"pixrem": "^1.1.0",
3637
"pleeease-filters": "^1.0.0",
3738
"postcss": "^4.0.2",

src/__tests__/cli.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,25 @@ test("cli", function(t) {
3535
)
3636
planned += 1
3737

38+
exec(
39+
cssnextBin +
40+
" src/__tests__/fixtures/cli.css" +
41+
" src/__tests__/fixtures/cli/output--io.css",
42+
function(err) {
43+
if (err) {
44+
throw err
45+
}
46+
const res = utils.readFixture("cli/output--io")
47+
t.equal(
48+
res,
49+
"body {\n color: #e00;\n background: url(../url);\n}\n",
50+
"should rebase url"
51+
)
52+
utils.remove("cli/output--io")
53+
}
54+
)
55+
planned += 1
56+
3857
exec(cssnextBin + " src/__tests__/fixtures/cli.css", function(err, stdout) {
3958
if (err) {
4059
throw err

src/__tests__/fixtures/cli.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44

55
body {
66
color: var(--red);
7+
background: url(url);
78
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
body {
22
color: #e00;
3+
background: url(url);
34
}

src/bin.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import path from "path"
88
// we will this instead of process.exit()
99
import exit from "exit"
1010

11+
import mkdirp from "mkdirp"
1112
import color from "chalk"
1213
import program from "commander"
1314

@@ -97,6 +98,12 @@ if (input && !fs.existsSync(input)) {
9798
}
9899

99100
config.from = input
101+
config.to = output
102+
103+
if (output) {
104+
mkdirp.sync(path.dirname(output))
105+
}
106+
100107
// init & adjust watcher with postcss-import dependencies
101108
let watcher
102109
if (config.watch) {

0 commit comments

Comments
 (0)