Skip to content

Commit 631513b

Browse files
author
David Narbutovich
committed
Update
1 parent bfdb503 commit 631513b

File tree

8 files changed

+1065
-580
lines changed

8 files changed

+1065
-580
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"@babel/preset-env",
55
{
66
"targets": {
7-
"node": ["6.11.0"]
7+
"node": "6.11.0"
88
}
99
}
1010
]

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
node_modules/
22
lib/
33
test/b.css
4-
.idea/
54
yarn-error.log

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
sudo: false
2+
language: node_js
3+
node_js:
4+
- "10"
5+
- "8"
6+
install:
7+
- yarn
8+
script:
9+
- yarn test

CHANGELOG.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Change Log
22

3+
## 3.0.0
4+
- Update babel
5+
- Update dependencies
6+
- Add test
7+
38
## 2.0.0
4-
* deprecated node@4.x.x
5-
* deprecated webpack@1.x.x
6-
* added `sourceMap: true|false` options (based on postcss)
9+
10+
- deprecated node@4.x.x
11+
- deprecated webpack@1.x.x
12+
- added `sourceMap: true|false` options (based on postcss)

appveyor.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
os: Visual Studio 2015
2+
platform: x64
3+
environment:
4+
matrix:
5+
- nodejs_version: "10"
6+
- nodejs_version: "8"
7+
8+
install:
9+
- ps: Install-Product node $env:nodejs_version x64
10+
- yarn install
11+
12+
test_script:
13+
- node --version
14+
- yarn --version
15+
- yarn test
16+
17+
build: off
18+
deploy: off

package.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,23 @@
66
"lib"
77
],
88
"dependencies": {
9-
"loader-utils": "^1.1.0",
10-
"postcss": "^6.0.0"
9+
"loader-utils": "^1.1.0"
1110
},
1211
"peerDependencies": {
12+
"postcss": ">=6.0.0",
1313
"webpack": ">=2.0.0"
1414
},
1515
"scripts": {
16-
"build": "babel src --out-dir lib"
16+
"prebuild": "rimraf ./lib",
17+
"build": "babel src --out-dir lib",
18+
"test": "npm run build; node ./test/test.js"
1719
},
1820
"devDependencies": {
19-
"@babel/cli": "^7.0.0-beta.46",
20-
"@babel/core": "^7.0.0-beta.46",
21-
"@babel/preset-env": "^7.0.0-beta.46"
21+
"@babel/cli": "^7.0.0",
22+
"@babel/core": "^7.0.0",
23+
"@babel/preset-env": "^7.0.0",
24+
"postcss": "^7.0.0",
25+
"rimraf": "^2.6.2"
2226
},
2327
"engines": {
2428
"node": ">=6.11.0"

test/test.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
1-
const fs = require("fs");
1+
const { readFileSync, writeFileSync } = require("fs");
2+
const { resolve } = require("path");
3+
const { equal } = require("assert");
4+
25
const postcss = require("postcss");
6+
37
const { groupCssMediaQueries } = require("../lib/group-css-media-queries");
48

9+
const expectedResult = `.foo{width:240px;}.bar{width:160px;}.header-main{background-image:url("/images/branding/logo.main.png");}.footer-main{background-image:url("/images/branding/logo.main.png");}@mediascreenand(min-width:768px){.foo{width:576px;}.bar{width:384px;}}@mediaalland(-webkit-min-device-pixel-ratio:1.5),(min--moz-device-pixel-ratio:1.5),(-o-min-device-pixel-ratio:1.5/1),(min-device-pixel-ratio:1.5),(min-resolution:138dpi),(min-resolution:1.5dppx){.header-main{background-image:url("/images/branding/logo.main@2x.png");-webkit-background-size:autoauto;-moz-background-size:autoauto;background-size:autoauto;}.footer-main{background-image:url("/images/branding/logo.main@2x.png");-webkit-background-size:autoauto;-moz-background-size:autoauto;background-size:autoauto;}}`;
10+
511
(async () => {
6-
try {
7-
const result = await postcss(groupCssMediaQueries).process(
8-
fs.readFileSync("a.css"),
9-
{
10-
from: "a.css"
11-
}
12-
);
13-
fs.writeFileSync("b.css", result.css);
14-
} catch (err) {
15-
console.log(err);
16-
}
12+
const [from, to] = [resolve(__dirname, "a.css"), resolve(__dirname, "b.css")];
13+
14+
const result = await postcss(groupCssMediaQueries).process(
15+
readFileSync(from),
16+
{
17+
from,
18+
to
19+
}
20+
);
21+
22+
writeFileSync(to, result.css);
23+
24+
equal(result.css.replace(/\s+/g, ""), expectedResult);
25+
26+
console.log(" --- Test successful");
1727
})();

0 commit comments

Comments
 (0)