Last active
January 12, 2016 22:59
-
-
Save bellerus/10414499 to your computer and use it in GitHub Desktop.
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
# grunt-newer: | |
# Check for newer @import .less files example | |
# See: https://github.com/tschaub/grunt-newer/issues/29 | |
# CoffeeScript version of @cgmartin https://gist.github.com/cgmartin/10328349 | |
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 | |
match | |
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 | |
break | |
action shouldInclude | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment