Last active
January 4, 2016 01:09
-
-
Save spencercarnage/8546684 to your computer and use it in GitHub Desktop.
Execute commands from CLI to perform specfic Grunt task(s) after Compass compilation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add this to your Compass config.rb to perform a Grunt-specific task after Compass | |
# compiles your Sass. | |
# see if a shell command exists | |
def which(cmd) | |
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] | |
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| | |
exts.each { |ext| | |
exe = File.join(path, "#{cmd}#{ext}") | |
return exe if File.executable? exe | |
} | |
end | |
return nil | |
end | |
# Callback for triggering grunt-related tasks | |
on_stylesheet_saved do |filename| | |
rel = filename.split(Dir.pwd.to_s)[1].sub('/', '') | |
if which('grunt') != nil | |
# Change the grunt command to anything you want | |
system("grunt compass:minify --file=#{rel}") | |
else | |
puts 'Please install Node.JS w/ Grunt to fire Compass compile callback to minify production version of CSS file' | |
end | |
end | |
# PS I suck at Ruby. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment