I want to run sass from within Ruby script. Compiling a scss file scss
can be done by doing:
require "sass"
Sass::Engine.new(File.read(scss), options).render
with some appropriate hash assigned to options
, but I want to compile it only if scss
or any of its partial (imported) files if updated.
Within options
, I have sass caching turned on. Caching keeps all the update information of the relevant files in a certain directory. I feel that, by doing up to:
engine = Sass::Engine.new(File.read(scss), options)
there must be information available in engine
by which I can tell if scss
or any of its partial files is updated. Only in such case, I should run:
engine.render
to do the compiling. How can I detect the file update based on the sass cache?