File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ mod printer;
1818mod traits;
1919mod macros;
2020
21- use napi:: { CallContext , JsObject , JsUndefined } ;
21+ use napi:: { CallContext , JsObject , JsBuffer } ;
2222use serde:: { Deserialize , Serialize } ;
2323use cssparser:: { Parser , ParserInput , RuleListParser } ;
2424use crate :: traits:: ToCss ;
@@ -35,7 +35,7 @@ struct Config {
3535}
3636
3737#[ js_function( 1 ) ]
38- fn transform ( ctx : CallContext ) -> napi:: Result < JsUndefined > {
38+ fn transform ( ctx : CallContext ) -> napi:: Result < JsBuffer > {
3939 let opts = ctx. get :: < JsObject > ( 0 ) ?;
4040 let config: Config = ctx. env . from_js_value ( opts) ?;
4141
@@ -46,9 +46,8 @@ fn transform(ctx: CallContext) -> napi::Result<JsUndefined> {
4646 // }
4747
4848 let res = compile ( code, true ) ;
49- println ! ( "{}" , res) ;
5049
51- ctx. env . get_undefined ( )
50+ Ok ( ctx. env . create_buffer_with_data ( res . into_bytes ( ) ) ? . into_raw ( ) )
5251}
5352
5453fn compile ( code : & str , minify : bool ) -> String {
Original file line number Diff line number Diff line change 11const css = require ( './native' ) ;
22
33css . transform ( {
4+
5+ let res = css . transform ( {
46 filename : __filename ,
57 code : Buffer . from ( `
68
@@ -103,4 +105,6 @@ css.transform({
103105 background: green;
104106 }
105107}
106- ` ) } )
108+ ` ) } ) ;
109+
110+ console . log ( res . toString ( ) ) ;
You can’t perform that action at this time.
0 commit comments