This repository was archived by the owner on Mar 28, 2018. It is now read-only.
File tree 5 files changed +53
-8
lines changed
5 files changed +53
-8
lines changed Original file line number Diff line number Diff line change
1
+ node_modules
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- module . exports = function postcssCssstats ( options ) {
4
- options = options || { } ;
3
+ var _ = require ( 'lodash' ) ;
4
+ var postcss = require ( 'postcss' ) ;
5
+ var cssstats = require ( 'cssstats' ) ;
5
6
6
- return true ;
7
- } ;
7
+ module . exports = postcss . plugin ( 'cssstats' , function ( options , callback ) {
8
+ if ( _ . isFunction ( options ) ) {
9
+ callback = options ;
10
+ options = { } ;
11
+ } else {
12
+ options = options || { } ;
13
+ callback = callback || _ . noop ;
14
+ }
15
+
16
+ return function ( css , postcssResult ) {
17
+ // XXX TODO: cssstats should also be able to handle an AST
18
+ callback ( cssstats ( css . toString ( ) ) ) ;
19
+ } ;
20
+ } ) ;
Original file line number Diff line number Diff line change 15
15
"url" : " https://github.com/cssstats/postcss-cssstats.git"
16
16
},
17
17
"keywords" : [
18
-
18
+ " cssstats" ,
19
+ " css" ,
20
+ " stats" ,
21
+ " statistics" ,
22
+ " postcss" ,
23
+ " postcss-plugin"
19
24
],
20
25
"license" : " MIT" ,
21
26
"bugs" : {
22
27
"url" : " https://github.com/cssstats/postcss-cssstats/issues"
23
28
},
24
29
"homepage" : " https://github.com/cssstats/postcss-cssstats" ,
25
- "dependencies" : {},
30
+ "dependencies" : {
31
+ "cssstats" : " ^1.5.1" ,
32
+ "lodash" : " ^3.8.0" ,
33
+ "postcss" : " ^4.1.9"
34
+ },
26
35
"devDependencies" : {
36
+ "is-present" : " 0.0.1" ,
27
37
"mocha" : " *"
28
38
}
29
39
}
Original file line number Diff line number Diff line change
1
+ .foo {
2
+ color : tomato;
3
+ }
4
+
5
+ .bar .baz {
6
+ color : hotpink;
7
+ }
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
+ var fs = require ( 'fs' ) ;
3
4
var assert = require ( 'assert' ) ;
5
+ var postcss = require ( 'postcss' ) ;
6
+ var isPresent = require ( 'is-present' ) ;
4
7
var postcssCssstats = require ( '..' ) ;
5
8
6
9
describe ( 'postcss-cssstats' , function ( ) {
7
10
8
- it ( 'should do something awesome' , function ( ) {
9
- assert . equal ( postcssCssstats ( ) , true ) ;
11
+ it ( 'should return a stats object' , function ( done ) {
12
+ postcss ( )
13
+ . use ( postcssCssstats ( { } , function ( stats ) {
14
+ assert . ok ( isPresent ( stats ) ) ;
15
+ } ) )
16
+ . process ( fixture ( 'basic' ) )
17
+ . then ( function ( ) {
18
+ done ( ) ;
19
+ } ) ;
10
20
} ) ;
11
21
} ) ;
22
+
23
+ function fixture ( name ) {
24
+ return fs . readFileSync ( 'test/fixtures/' + name + '.css' , 'utf8' ) . toString ( ) ;
25
+ }
You can’t perform that action at this time.
0 commit comments