@@ -60,6 +60,8 @@ fn main() -> Result<()> {
60
60
process:: exit ( 1 ) ;
61
61
} ) ;
62
62
63
+ let minify_output = args. get ( 2 ) ;
64
+
63
65
if let Err ( e) = env:: set_current_dir ( Path :: new ( path) ) {
64
66
eprintln ! (
65
67
"\n {}Error{}: Failed to set current directory: {}" ,
@@ -109,6 +111,7 @@ fn main() -> Result<()> {
109
111
110
112
let mut files_count = 0 ;
111
113
let mut errors_count = 0 ;
114
+ let minify = minify_output. map_or ( "" , |v| v) == "--minify" ;
112
115
113
116
for ( css_file, mut classes_tsx) in defined_classnames. clone ( ) {
114
117
if let Some ( used_css) = used_classnames. get ( & css_file) {
@@ -124,20 +127,36 @@ fn main() -> Result<()> {
124
127
files_count += 1 ;
125
128
errors_count += classes_tsx. len ( ) ;
126
129
127
- println ! ( "{}{}{}" , COLOR_BLUE , css_file, COLOR_RESET ) ;
130
+ if !minify {
131
+ println ! ( "{}{}{}" , COLOR_BLUE , css_file, COLOR_RESET ) ;
132
+ }
133
+
128
134
for extra in classes_tsx {
129
- println ! (
130
- "{}{}:{} {}Warn{}: Unused class `{}` found" ,
131
- COLOR_YELLOW ,
132
- extra. line_index + 1 ,
133
- extra. column_index + 1 ,
134
- COLOR_YELLOW ,
135
- COLOR_RESET ,
136
- extra. class_name
137
- ) ;
135
+ if !minify {
136
+ println ! (
137
+ "{}{}:{} {}Warn{}: Unused class `{}` found" ,
138
+ COLOR_YELLOW ,
139
+ extra. line_index + 1 ,
140
+ extra. column_index + 1 ,
141
+ COLOR_YELLOW ,
142
+ COLOR_RESET ,
143
+ extra. class_name
144
+ ) ;
145
+ } else {
146
+ println ! (
147
+ "{}:{}:{}:{}:Unused class `{}` found" ,
148
+ css_file,
149
+ extra. line_index + 1 ,
150
+ extra. column_index + 1 ,
151
+ extra. class_name. len( ) ,
152
+ extra. class_name
153
+ ) ;
154
+ }
138
155
}
139
156
140
- println ! ( ) ;
157
+ if !minify {
158
+ println ! ( ) ;
159
+ }
141
160
}
142
161
143
162
let mut undefined_classes: HashMap < String , HashSet < UsedClassName > > = HashMap :: new ( ) ;
@@ -165,29 +184,46 @@ fn main() -> Result<()> {
165
184
}
166
185
167
186
for undefined in undefined_classes {
168
- println ! ( "{}{}{}" , COLOR_BLUE , undefined. 0 , COLOR_RESET ) ;
187
+ if !minify {
188
+ println ! ( "{}{}{}" , COLOR_BLUE , undefined. 0 , COLOR_RESET ) ;
189
+ }
169
190
for extra in undefined. 1 {
170
- println ! (
171
- "{}{}:{} {}Warn{}: Undefined class `{}` used" ,
172
- COLOR_YELLOW ,
173
- extra. line,
174
- extra. column + 1 ,
175
- COLOR_YELLOW ,
176
- COLOR_RESET ,
177
- extra. class_name
178
- ) ;
191
+ if !minify {
192
+ println ! (
193
+ "{}{}:{} {}Warn{}: Undefined class `{}` used" ,
194
+ COLOR_YELLOW ,
195
+ extra. line,
196
+ extra. column + 1 ,
197
+ COLOR_YELLOW ,
198
+ COLOR_RESET ,
199
+ extra. class_name
200
+ ) ;
201
+ } else {
202
+ println ! (
203
+ "{}:{}:{}:{}:Undefined class `{}` used" ,
204
+ undefined. 0 ,
205
+ extra. line,
206
+ extra. column + 1 ,
207
+ extra. class_name. len( ) ,
208
+ extra. class_name
209
+ ) ;
210
+ }
179
211
}
180
212
181
- println ! ( ) ;
213
+ if !minify {
214
+ println ! ( ) ;
215
+ }
182
216
}
183
217
184
- if errors_count == 0 {
185
- println ! ( "{}✔{} No CSS lint warnings found" , COLOR_GREEN , COLOR_RESET ) ;
186
- } else {
187
- println ! (
188
- "Found {}{} warnings{} in {} files" ,
189
- COLOR_YELLOW , errors_count, COLOR_RESET , files_count
190
- ) ;
218
+ if !minify {
219
+ if errors_count == 0 {
220
+ println ! ( "{}✔{} No CSS lint warnings found" , COLOR_GREEN , COLOR_RESET ) ;
221
+ } else {
222
+ println ! (
223
+ "Found {}{} warnings{} in {} files" ,
224
+ COLOR_YELLOW , errors_count, COLOR_RESET , files_count
225
+ ) ;
226
+ }
191
227
}
192
228
193
229
Ok ( ( ) )
0 commit comments