Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# grunt-newer:
# Check for newer @import .less files example
# See:
# CoffeeScript version of @cgmartin
checkForModifiedImports = (details, action) ->
lessFile = details.path
mTime = details.time
fs.readFile lessFile, "utf8", (err, data) ->
lessDir = path.dirname lessFile
regex = /@import "(.+?)(\.less)?";/g
shouldInclude = false
while (match = regex.exec(data)) isnt null
importFile = "#{lessDir}/#{match[1]}.less"
if fs.existsSync importFile
stat = fs.statSync importFile
if stat.mtime > mTime
shouldInclude = true
action shouldInclude
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.