Revert "Run again if interrupt off and triggered during previous run. Closes GH-33."

This reverts commit d01491be1b.
This commit is contained in:
Kyle Robinson Young 2013-05-07 11:32:24 -07:00
parent f1af227d22
commit f8a7b3cebe
3 changed files with 4 additions and 36 deletions

View File

@ -42,8 +42,6 @@ module.exports = function(grunt) {
this.nameArgs = []; this.nameArgs = [];
// A list of changed files to feed to task runs for livereload // A list of changed files to feed to task runs for livereload
this.changedFiles = Object.create(null); this.changedFiles = Object.create(null);
// Flag to set if interrupt is false and a change happened during a task run
this.needsAnotherRun = false;
} }
util.inherits(Runner, EE); util.inherits(Runner, EE);
@ -150,7 +148,6 @@ module.exports = function(grunt) {
self.interrupt(); self.interrupt();
} else { } else {
// Dont interrupt the tasks running // Dont interrupt the tasks running
self.needsAnotherRun = true;
return; return;
} }
} }
@ -218,26 +215,15 @@ module.exports = function(grunt) {
var self = this; var self = this;
if (self.running === false) { return; } if (self.running === false) { return; }
self.running = false; self.running = false;
var time = 0; var time = 0;
self._queue.forEach(function(name, i) { self._queue.forEach(function(name, i) {
var target = self._targets[name]; var target = self._targets[name];
if (!target) { return; } if (!target) { return; }
if (target.startedAt !== false) { if (target.startedAt !== false) {
time += target.complete(); time += target.complete();
if (self.needsAnotherRun !== true) { self._queue[i] = null;
self._queue[i] = null;
}
} }
}); });
// If it needs another run
if (self.needsAnotherRun === true) {
self.needsAnotherRun = false;
self.run();
return;
}
var elapsed = (time > 0) ? Number(time / 1000) : 0; var elapsed = (time > 0) ? Number(time / 1000) : 0;
self.changedFiles = Object.create(null); self.changedFiles = Object.create(null);
self.emit('end', elapsed); self.emit('end', elapsed);

View File

@ -2,7 +2,7 @@
* grunt-contrib-watch * grunt-contrib-watch
* http://gruntjs.com/ * http://gruntjs.com/
* *
* Copyright (c) 2013 "Cowboy" Ben Alman, contributors * Copyright (c) 2012 "Cowboy" Ben Alman, contributors
* Licensed under the MIT license. * Licensed under the MIT license.
*/ */
@ -10,7 +10,7 @@ module.exports = function(grunt) {
'use strict'; 'use strict';
grunt.registerMultiTask('echo', 'A task that echos a message.', function() { grunt.registerMultiTask('echo', 'A task that echos a message.', function() {
var msg = this.data.message || 'I do absolutely nothing.'; var msg = this.data.message || 'I do absolutely nothing.';
var wait = this.data.wait || grunt.option('wait') || 0; var wait = this.data.wait || 0;
var fail = this.data.fail || false; var fail = this.data.fail || false;
var done = this.async(); var done = this.async();

View File

@ -125,23 +125,5 @@ exports.watchConfig = {
test.equal(grunt.util._(result).count('Waiting...'), 2, 'Should have displayed "Wating..." twice'); test.equal(grunt.util._(result).count('Waiting...'), 2, 'Should have displayed "Wating..." twice');
test.done(); test.done();
}); });
}, }
runAgainNotInterrupted: function(test) {
test.expect(1);
var cwd = path.resolve(fixtures, 'multiTargets');
var assertWatch = helper.assertTask(['watch:one', '--wait=4000'], {cwd:cwd});
assertWatch([function() {
grunt.file.write(path.join(cwd, 'lib', 'one.js'), 'var test = true;');
setTimeout(function() {
grunt.file.write(path.join(cwd, 'lib', 'one.js'), 'var test = true;');
}, 2000);
setTimeout(function() {
grunt.file.write(path.join(cwd, 'lib', 'one.js'), 'var test = true;');
}, 3000);
}], function(result) {
helper.verboseLog(result);
test.equal(grunt.util._(result).count('one has changed'), 2, 'Should have ran the one task twice.');
test.done();
});
},
}; };