Forked from bellerus/checkForModifiedImports.coffee
Last active
August 29, 2015 14:06
Star
You must be signed in to star a gist
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 .scss files example(CoffeeScript version) | |
# Customized of @bellerus https://gist.github.com/bellerus/10414499 | |
# See: https://github.com/tschaub/grunt-newer/issues/29 | |
module.exports.checkForModifiedImports = (details, action) -> | |
fs = require('fs') | |
path = require('path') | |
scssFile = details.path | |
mTime = details.time | |
fs.readFile scssFile, "utf8", (err, data) -> | |
scssDir = path.dirname scssFile | |
regex = /@import "(.+?)(\.scss)?";/g | |
shouldInclude = false | |
match | |
while (match = regex.exec(data)) isnt null | |
importFile = "#{scssDir}/_#{match[1]}.scss" | |
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