Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@spencercarnage
Last active January 4, 2016 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spencercarnage/8546684 to your computer and use it in GitHub Desktop.
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
# 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