@@ -212,7 +212,7 @@ void print_usage(char* argv0) {
212
212
printf (" --line-comments\n" );
213
213
printf (" -I, --load-path PATH Set Sass import path.\n" );
214
214
printf (" -P, --plugin-path PATH Set path to autoload plugins.\n" );
215
- printf (" -m, --sourcemap Emit source map.\n" );
215
+ printf (" -m, --sourcemap[=TYPE] Emit source map (auto or inline) .\n" );
216
216
printf (" -M, --omit-map-comment Omits the source map url comment.\n" );
217
217
printf (" -p, --precision Set the precision for numbers.\n" );
218
218
printf (" -a, --sass Treat input as indented syntax.\n" );
@@ -246,6 +246,7 @@ int main(int argc, char** argv) {
246
246
247
247
char * outfile = 0 ;
248
248
int from_stdin = 0 ;
249
+ bool auto_source_map = false;
249
250
bool generate_source_map = false;
250
251
struct Sass_Options * options = sass_make_options ();
251
252
sass_option_set_output_style (options , SASS_STYLE_NESTED );
@@ -262,15 +263,15 @@ int main(int argc, char** argv) {
262
263
{ "style" , required_argument , 0 , 't' },
263
264
{ "line-numbers" , no_argument , 0 , 'l' },
264
265
{ "line-comments" , no_argument , 0 , 'l' },
265
- { "sourcemap" , no_argument , 0 , 'm' },
266
+ { "sourcemap" , optional_argument , 0 , 'm' },
266
267
{ "omit-map-comment" , no_argument , 0 , 'M' },
267
268
{ "precision" , required_argument , 0 , 'p' },
268
269
{ "version" , no_argument , 0 , 'v' },
269
270
{ "sass" , no_argument , 0 , 'a' },
270
271
{ "help" , no_argument , 0 , 'h' },
271
272
{ NULL , 0 , NULL , 0 }
272
273
};
273
- while ((c = getopt_long (argc , argv , "vhslmMap :t:I:P:" , long_options , & long_index )) != -1 ) {
274
+ while ((c = getopt_long (argc , argv , "vhsl:mMap :t:I:P:" , long_options , & long_index )) != -1 ) {
274
275
switch (c ) {
275
276
case 's' :
276
277
from_stdin = 1 ;
@@ -301,6 +302,20 @@ int main(int argc, char** argv) {
301
302
sass_option_set_source_comments (options , true);
302
303
break ;
303
304
case 'm' :
305
+ if (optarg ) { // optional argument
306
+ if (strcmp (optarg , "auto" ) == 0 ) {
307
+ auto_source_map = true;
308
+ } else if (strcmp (optarg , "inline" ) == 0 ) {
309
+ sass_option_set_source_map_embed (options , true);
310
+ } else {
311
+ fprintf (stderr , "Invalid argument for -m flag: '%s'. Allowed arguments are:" , optarg );
312
+ fprintf (stderr , " %s" , "auto inline" );
313
+ fprintf (stderr , "\n" );
314
+ invalid_usage (argv [0 ]);
315
+ }
316
+ } else {
317
+ auto_source_map = true;
318
+ }
304
319
generate_source_map = true;
305
320
break ;
306
321
case 'M' :
@@ -349,6 +364,8 @@ int main(int argc, char** argv) {
349
364
strcpy (source_map_file , outfile );
350
365
strcat (source_map_file , extension );
351
366
sass_option_set_source_map_file (options , source_map_file );
367
+ } else if (auto_source_map ) {
368
+ sass_option_set_source_map_embed (options , true);
352
369
}
353
370
result = compile_file (options , argv [optind ], outfile );
354
371
} else {
0 commit comments