@@ -13,6 +13,12 @@ function fixtureContent(filepath) {
13
13
return fs . readFileSync ( fixturePath ( filepath ) , 'utf-8' ) . trim ( ) ;
14
14
}
15
15
16
+ function bufferFrom ( data , encoding ) {
17
+ return typeof Buffer . from === 'function'
18
+ ? Buffer . from ( data , encoding )
19
+ : new Buffer ( data , encoding ) ;
20
+ }
21
+
16
22
function run ( ) {
17
23
var args = [ path . join ( __dirname , '../bin/csso' ) ] . concat ( Array . prototype . slice . call ( arguments ) ) ;
18
24
var proc = child . spawn ( cmd , args , { stdio : 'pipe' } ) ;
@@ -59,9 +65,8 @@ function run() {
59
65
}
60
66
61
67
it ( 'should output version' , function ( ) {
62
- return run ( '-v' ) . output (
63
- require ( 'csso/package.json' ) . version
64
- ) ;
68
+ return run ( '-v' )
69
+ . output ( require ( 'csso/package.json' ) . version ) ;
65
70
} ) ;
66
71
67
72
it ( 'should read content from stdin if no file specified' , function ( ) {
@@ -79,7 +84,7 @@ it('--source-map inline', function() {
79
84
return run ( fixturePath ( '1.css' ) , '--source-map' , 'inline' )
80
85
. output ( function ( res ) {
81
86
var expected = fixtureContent ( '1.min.css.map' ) ;
82
- var actual = new Buffer ( String ( res ) . match ( / d a t a : a p p l i c a t i o n \/ j s o n ; b a s e 6 4 , ( .+ ) / ) [ 1 ] , 'base64' ) . toString ( 'utf-8' ) ;
87
+ var actual = bufferFrom ( String ( res ) . match ( / d a t a : a p p l i c a t i o n \/ j s o n ; b a s e 6 4 , ( .+ ) / ) [ 1 ] , 'base64' ) . toString ( 'utf-8' ) ;
83
88
84
89
assert . equal ( actual , expected ) ;
85
90
} ) ;
0 commit comments