diff --git a/lib/coffee-script/command.js b/lib/coffee-script/command.js index 6356165c..da330b39 100644 --- a/lib/coffee-script/command.js +++ b/lib/coffee-script/command.js @@ -176,9 +176,9 @@ return code === null; })) { clearTimeout(joinTimeout); - return joinTimeout = setTimeout(function() { + return joinTimeout = wait(100, function() { return compileScript(opts.join, sourceCode.join('\n'), opts.join); - }, 100); + }); } }; @@ -255,7 +255,7 @@ try { return watcher = fs.watch(source, function() { clearTimeout(readdirTimeout); - return readdirTimeout = setTimeout(function() { + return readdirTimeout = wait(25, function() { return fs.readdir(source, function(err, files) { var file, _i, _len, _results; if (err) { @@ -281,7 +281,7 @@ } return _results; }); - }, 25); + }); }); } catch (e) { if (e.code !== 'ENOENT') throw e; diff --git a/src/command.coffee b/src/command.coffee index fd55b25f..84fa0635 100644 --- a/src/command.coffee +++ b/src/command.coffee @@ -157,9 +157,8 @@ compileJoin = -> return unless opts.join unless sourceCode.some((code) -> code is null) clearTimeout joinTimeout - joinTimeout = setTimeout -> + joinTimeout = wait 100, -> compileScript opts.join, sourceCode.join('\n'), opts.join - , 100 # Load files that are to-be-required before compilation occurs. loadRequires = -> @@ -222,7 +221,7 @@ watchDir = (source, base) -> try watcher = fs.watch source, -> clearTimeout readdirTimeout - readdirTimeout = setTimeout -> + readdirTimeout = wait 25, -> fs.readdir source, (err, files) -> if err throw err unless err.code is 'ENOENT' @@ -234,7 +233,6 @@ watchDir = (source, base) -> sources.push file sourceCode.push null compilePath file, no, base - , 25 catch e throw e unless e.code is 'ENOENT'