CSS-Sass
view release on metacpan or search on metacpan
bin/psass.pl view on Meta::CPAN
#!/usr/bin/perl
####################################################################################################
# sass (scss) compiler
####################################################################################################
use strict;
use warnings;
####################################################################################################
# dependencies
####################################################################################################
# parse options
use Pod::Usage;
use Getopt::Long;
# convenient file handling
use File::Slurp qw(write_file);
# load constants from libsass
use CSS::Sass qw(SASS_STYLE_EXPANDED);
use CSS::Sass qw(SASS_STYLE_NESTED);
use CSS::Sass qw(SASS_STYLE_COMPRESSED);
use CSS::Sass qw(SASS_STYLE_COMPACT);
use CSS::Sass::Watchdog qw(start_watchdog);
####################################################################################################
# normalize command arguments to utf8
####################################################################################################
# get cmd arg encoding
use Encode::Locale qw();
# convert cmd args to utf8
use Encode qw(decode encode);
# now just decode every command arguments
@ARGV = map { decode(locale => $_, 1) } @ARGV;
####################################################################################################
# config variables
####################################################################################################
# init options
my $watchdog;
my $benchmark;
my $precision;
my $output_file;
my $output_style;
my $source_comments;
my $source_map_file;
my $source_map_embed;
my $source_map_contents;
my $omit_source_map_url;
# define a sub to print out the version (mimic behaviour of node.js blessc)
# this script has it's own version numbering as it's not dependent on any libs
sub version {
printf "psass %s (perl sass/scss compiler)\n", "0.4.0";
printf " libsass: %s\n", CSS::Sass::libsass_version();
printf " sass2scss: %s\n", CSS::Sass::sass2scss_version();
exit 0 };
# paths arrays
my @plugin_paths;
my @include_paths;
# output styles
my $indent = " ";
my $linefeed = "auto";
# get options
GetOptions (
'help|h' => sub { pod2usage(1); },
'watch|w!' => \ $watchdog,
'version|v' => \ &version,
'benchmark|b!' => \ $benchmark,
'indent=s' => \ $indent,
'linefeed=s' => \ $linefeed,
'precision|p=s' => \ $precision,
'output-file|o=s' => \ $output_file,
'output-style|t=s' => \ $output_style,
'source-comments|c!' => \ $source_comments,
'source-map-file|m=s' => \ $source_map_file,
'source-map-embed|e!' => \ $source_map_embed,
'source-map-contents|s!' => \ $source_map_contents,
'no-source-map-url!' => \ $omit_source_map_url,
'plugin-path|L=s' => sub { push @plugin_paths, $_[1] },
'include-path|I=s' => sub { push @include_paths, $_[1] }
);
# set default if not configured
unless (defined $output_style)
{ $output_style = SASS_STYLE_NESTED }
# parse string to constant
elsif ($output_style =~ m/^n/i)
{ $output_style = SASS_STYLE_NESTED }
( run in 1.045 second using v1.01-cache-2.11-cpan-5a3173703d6 )