Lint tweaks.
This commit is contained in:
parent
e42386acf3
commit
fd3ed7a0ac
14
Gruntfile.js
14
Gruntfile.js
@ -14,11 +14,11 @@ module.exports = function(grunt) {
|
||||
all: [
|
||||
'Gruntfile.js',
|
||||
'tasks/**/*.js',
|
||||
'<%= nodeunit.tests %>',
|
||||
'<%= nodeunit.tests %>'
|
||||
],
|
||||
options: {
|
||||
jshintrc: '.jshintrc',
|
||||
},
|
||||
jshintrc: '.jshintrc'
|
||||
}
|
||||
},
|
||||
jscs: {
|
||||
src: ['tasks/**/*.js', 'test/tasks/**/*.js'],
|
||||
@ -29,12 +29,12 @@ module.exports = function(grunt) {
|
||||
watch: {
|
||||
all: {
|
||||
files: ['<%= jshint.all %>'],
|
||||
tasks: ['jshint', 'nodeunit'],
|
||||
},
|
||||
tasks: ['jshint', 'nodeunit']
|
||||
}
|
||||
},
|
||||
nodeunit: {
|
||||
tests: ['test/tasks/*_test.js'],
|
||||
},
|
||||
tests: ['test/tasks/*_test.js']
|
||||
}
|
||||
});
|
||||
|
||||
// Dynamic alias task to nodeunit. Run individual tests with: grunt test:events
|
||||
|
@ -161,5 +161,5 @@ exports.events = {
|
||||
test.ok(result.indexOf('Ive changed') !== -1, 'should run task set in event listener');
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -51,5 +51,5 @@ exports.fail = {
|
||||
test.ok(result.match(/This task should be fatal/g).length === 2, 'grunt.fatal should not stop the watch task.');
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -10,7 +10,9 @@ helper.fixtures = path.join(__dirname, '..', 'fixtures');
|
||||
// If verbose flag set, display output
|
||||
helper.verboseLog = function() {};
|
||||
if (_.indexOf(process.argv, '-v') !== -1) {
|
||||
helper.verboseLog = function() { console.log.apply(null, arguments); };
|
||||
helper.verboseLog = function() {
|
||||
console.log.apply(null, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
// helper for creating assertTasks for testing tasks in child processes
|
||||
@ -73,7 +75,9 @@ helper.assertTask = function assertTask(task, options) {
|
||||
if (shouldRun) {
|
||||
setTimeout(function() {
|
||||
var run = runs.shift();
|
||||
if (typeof run === 'function') { run(); }
|
||||
if (typeof run === 'function') {
|
||||
run();
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
@ -94,7 +98,9 @@ helper.assertTask = function assertTask(task, options) {
|
||||
|
||||
// clean up files within fixtures
|
||||
helper.cleanUp = function cleanUp(files) {
|
||||
if (typeof files === 'string') { files = [files]; }
|
||||
if (typeof files === 'string') {
|
||||
files = [files];
|
||||
}
|
||||
files.forEach(function(filepath) {
|
||||
filepath = path.join(helper.fixtures, filepath);
|
||||
if (grunt.file.exists(filepath)) {
|
||||
|
@ -10,7 +10,7 @@ var fixtures = helper.fixtures;
|
||||
|
||||
function cleanUp() {
|
||||
helper.cleanUp([
|
||||
'livereload/node_modules',
|
||||
'livereload/node_modules'
|
||||
]);
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ function request(port, done) {
|
||||
var data = '';
|
||||
var req = http.request({
|
||||
hostname: 'localhost',
|
||||
port: port,
|
||||
port: port
|
||||
}, function(res) {
|
||||
res.setEncoding('utf8');
|
||||
res.on('data', function(chunk) {
|
||||
@ -235,5 +235,5 @@ exports.livereload = {
|
||||
'Should not livereload when a task errors with flag and spawn=false');
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -35,7 +35,7 @@ exports.nospawn = {
|
||||
grunt.file.write(path.join(cwd, 'lib', 'nospawn.js'), write);
|
||||
}, function(result) {
|
||||
helper.verboseLog(result);
|
||||
var count = result.match((new RegExp('Running "watch" task', 'g'))).length;
|
||||
var count = result.match(new RegExp('Running "watch" task', 'g')).length;
|
||||
test.equal(count, 2, 'Watch should have fired twice.');
|
||||
test.ok(result.indexOf('Server is listening...') !== -1, 'server should have been started.');
|
||||
test.ok(result.indexOf('Server is talking!') !== -1, 'server should have responded.');
|
||||
@ -56,10 +56,10 @@ exports.nospawn = {
|
||||
// Two functions needed to run two rounds of watching
|
||||
}], function(result) {
|
||||
helper.verboseLog(result);
|
||||
var count = result.match((new RegExp('Running "long" task', 'g'))).length;
|
||||
var count = result.match(new RegExp('Running "long" task', 'g')).length;
|
||||
test.equal(count, 4, 'long task should have been ran only 4 times.');
|
||||
test.ok(result.indexOf('have been interrupted') !== -1, 'tasks should have been interrupted.');
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -40,5 +40,5 @@ exports.patterns = {
|
||||
'Watch should NOT have been triggered when dontedit.js was edited.');
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -10,7 +10,7 @@ var fixtures = helper.fixtures;
|
||||
function cleanUp() {
|
||||
helper.cleanUp([
|
||||
'multiTargets/node_modules',
|
||||
'multiTargets/Gruntfile.js.bak',
|
||||
'multiTargets/Gruntfile.js.bak'
|
||||
]);
|
||||
}
|
||||
|
||||
@ -45,11 +45,11 @@ exports.reloadgruntfile = {
|
||||
grunt.file.write(path.join(cwd, 'lib', 'one.js'), 'var one = true;');
|
||||
}], function(result) {
|
||||
helper.verboseLog(result);
|
||||
var count = result.match((new RegExp('Running "watch" task', 'g'))).length;
|
||||
var count = result.match(new RegExp('Running "watch" task', 'g')).length;
|
||||
test.equal(count, 2, 'Watch should have fired twice.');
|
||||
test.ok(result.indexOf('one has changed') !== -1, 'task one should have been triggered.');
|
||||
test.ok(result.indexOf('two has changed') !== -1, 'task two should have been triggered.');
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -33,7 +33,7 @@ exports.watch = {
|
||||
var cwd = path.resolve(fixtures, 'atBegin');
|
||||
var assertWatch = helper.assertTask(['watch', '--debug'], {cwd: cwd});
|
||||
assertWatch(function() {
|
||||
// noop. Does not modify any watched files.
|
||||
// noop. Does not modify any watched files.
|
||||
}, function(result) {
|
||||
helper.verboseLog(result);
|
||||
var firstIndex = result.indexOf('one has changed');
|
||||
|
Loading…
Reference in New Issue
Block a user