Permalink
Browse files

while loop hack for disapearing files ._.

small codestyle fix
  • Loading branch information...
1 parent 2f2a55e commit a0f4f4e9a38b9ca4e80229f3bdee70e2c2c3cd66 @3rd-Eden 3rd-Eden committed Apr 10, 2012
Showing with 24 additions and 6 deletions.
  1. +10 −1 lib/square.js
  2. +14 −5 lib/watch.js
View
@@ -376,7 +376,16 @@ Square.prototype.refresh = function refresh (files) {
if (!match) return;
- // update the latest shizzle
+ // there can be some sort of edge case where the file that we want to have
+ // is actually removed & added again from the disk by certain IDE's. So to
+ // get around this limitation we need to check if it's there, or just while
+ // loop until it's found again :D
+ if (!path.existsSync(meta.location)) {
+ while (!path.existsSync(meta.location)) {
+ // freeze the event loop, lol ;$
+ }
+ }
+
this.package.bundle[file].content = fs.readFileSync(meta.location, 'UTF8');
}.bind(this));
};
View
@@ -17,12 +17,21 @@ require('eventreactor');
module.exports = function watching (dir, extensions, fn) {
var changes = []
- , limited = _.throttle(function ratelimit () {
- fn.apply(fn, changes);
+ , limited;
- // clear the changes again
- changes.length = 0;
- }, 100);
+ /**
+ * Rate limit the change processor so it doesn't call the build function on
+ * each tiny file change
+ *
+ * @api private
+ */
+
+ limited = _.debounce(function ratelimit () {
+ fn.apply(fn, changes);
+
+ // clear the changes again
+ changes.length = 0;
+ }, 100);
/**
* Also add the extensions of pre-processors that compile to the array of

0 comments on commit a0f4f4e

Please sign in to comment.