Skip to content

Commit

Permalink
Emit file events so LESS dependency graph can be watched
Browse files Browse the repository at this point in the history
  • Loading branch information
bclinkinbeard committed Jul 31, 2014
1 parent 9bd7190 commit eb835c0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion less.js
@@ -1,11 +1,12 @@
var less = require('npm-less/less')
, path = require('path')
, events = require('events')
, resrc = require('resrcify/custom').resrc
, regexp = /url\([\"\'](.*?)[\"\']\)/g
, res
, assetsConfig

module.exports = function (opts, cb) {
var ctor = module.exports = function (opts, cb) {
assetsConfig = opts.assets

less(path.resolve(process.cwd(), opts.entry), {preprocess: preprocess}, function (err, output) {
Expand All @@ -15,7 +16,11 @@ module.exports = function (opts, cb) {
})
}

ctor.emitter = new events.EventEmitter()

function preprocess (file, src) {
ctor.emitter.emit('file', file)

if (!assetsConfig) return src

while ((res = regexp.exec(src)) !== null) {
Expand Down

0 comments on commit eb835c0

Please sign in to comment.