Skip to content
This repository has been archived by the owner on Dec 20, 2017. It is now read-only.

Commit

Permalink
fixed -w if glob in config file
Browse files Browse the repository at this point in the history
  • Loading branch information
jgallen23 committed Oct 16, 2012
1 parent 4d91e05 commit 0c80013
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions bin/masher.js
Expand Up @@ -6,6 +6,7 @@ var defaults = require('../lib/defaults');
var size = require('../lib/utils/size');
var fs = require('fs');
var findImports = require('../lib/utils/find-imports');
var glob = require('glob');

var version = JSON.parse(fs.readFileSync(__dirname + '/../package.json', 'utf8')).version

Expand Down Expand Up @@ -62,11 +63,23 @@ if (argv.help) {
}

//watch functionality
var watching = [];
var watch = function(arrObj) {

var timeout;

var watchFile = function(obj, file) {
if (watching.indexOf(file) != -1) {
return;
}
findImports(file, function(err, imports) {
imports.forEach(function(file) {
console.log('Watching '+file);
watchFile(obj, file);
});
});
watching.push(file);
console.log('Watching '+file);
fs.watch(file, function() {
if (timeout) {
clearTimeout(timeout)
Expand All @@ -87,11 +100,8 @@ var watch = function(arrObj) {

var watchObj = function(obj) {
obj.files.forEach(function(item) {
console.log('Watching '+item);
watchFile(obj, item);
findImports(item, function(err, imports) {
imports.forEach(function(file) {
console.log('Watching '+file);
glob(item, function(err, files) {
files.forEach(function(file) {
watchFile(obj, file);
});
});
Expand Down

0 comments on commit 0c80013

Please sign in to comment.