@@ -3,6 +3,7 @@ use std::collections::BTreeMap;
3
3
use std:: path:: Path ;
4
4
5
5
pub struct GeneratorOptions {
6
+ pub output_name : String ,
6
7
pub style : CodegenStyle ,
7
8
pub strip_extension : bool ,
8
9
}
@@ -35,9 +36,9 @@ impl Generator {
35
36
let data_value = self . build_data_value ( ) ;
36
37
let mut output = String :: new ( ) ;
37
38
38
- output. push_str ( "export = " ) ;
39
+ output. push_str ( & format ! ( "declare const {}: " , self . options . output_name ) ) ;
39
40
self . serialize_value_typescript ( & data_value, & mut output, 0 ) ;
40
- output. push ( ';' ) ;
41
+ output. push_str ( "; \n export = assets; \n " ) ;
41
42
42
43
output
43
44
}
@@ -109,7 +110,7 @@ impl Generator {
109
110
DataValue :: Node ( map) => {
110
111
output. push_str ( "{\n " ) ;
111
112
112
- let indent_str = " " . repeat ( indent + 1 ) ;
113
+ let indent_str = "\t " . repeat ( indent + 1 ) ;
113
114
114
115
for ( i, ( key, val) ) in map. iter ( ) . enumerate ( ) {
115
116
output. push_str ( & indent_str) ;
@@ -129,7 +130,7 @@ impl Generator {
129
130
output. push ( '\n' ) ;
130
131
}
131
132
132
- output. push_str ( & " " . repeat ( indent) ) ;
133
+ output. push_str ( & "\t " . repeat ( indent) ) ;
133
134
output. push ( '}' ) ;
134
135
}
135
136
}
@@ -144,7 +145,7 @@ impl Generator {
144
145
DataValue :: Node ( map) => {
145
146
output. push_str ( "{\n " ) ;
146
147
147
- let indent_str = " " . repeat ( indent + 1 ) ;
148
+ let indent_str = "\t " . repeat ( indent + 1 ) ;
148
149
149
150
for ( i, ( key, val) ) in map. iter ( ) . enumerate ( ) {
150
151
output. push_str ( & indent_str) ;
@@ -165,7 +166,7 @@ impl Generator {
165
166
output. push ( '\n' ) ;
166
167
}
167
168
168
- output. push_str ( & " " . repeat ( indent) ) ;
169
+ output. push_str ( & "\t " . repeat ( indent) ) ;
169
170
output. push ( '}' ) ;
170
171
}
171
172
}
0 commit comments