Shorter way to set livereload port
This commit is contained in:
parent
cbb0e8e0e4
commit
08a62f813b
@ -17,8 +17,13 @@ module.exports = function(grunt) {
|
||||
};
|
||||
|
||||
function LR(options) {
|
||||
if (options === true) { options = defaults; }
|
||||
else { options = grunt.util._.defaults(options, defaults); }
|
||||
if (options === true) {
|
||||
options = defaults;
|
||||
} else if (typeof options === 'number') {
|
||||
options = {port: options};
|
||||
} else {
|
||||
options = grunt.util._.defaults(options, defaults);
|
||||
}
|
||||
this.server = tinylr();
|
||||
this.server.listen(options.port, function(err) {
|
||||
if (err) { return grunt.fatal(err); }
|
||||
|
2
test/fixtures/livereload/Gruntfile.js
vendored
2
test/fixtures/livereload/Gruntfile.js
vendored
@ -24,7 +24,7 @@ module.exports = function(grunt) {
|
||||
tasks: ['before'],
|
||||
options: {
|
||||
nospawn: true,
|
||||
livereload: true,
|
||||
livereload: 1337,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -88,14 +88,14 @@ exports.livereload = {
|
||||
var cwd = path.resolve(fixtures, 'livereload');
|
||||
var assertWatch = helper.assertTask(['watch:nospawn', '-v'], {cwd: cwd});
|
||||
assertWatch([function() {
|
||||
request(35729, function(data) {
|
||||
request(1337, function(data) {
|
||||
resultData += data;
|
||||
grunt.file.write(path.join(cwd, 'lib', 'one.js'), 'var one = true;');
|
||||
});
|
||||
}], function(result) {
|
||||
helper.verboseLog(result);
|
||||
test.ok(result.indexOf('I ran before livereload.') !== -1, 'task should have ran before live reload.');
|
||||
test.ok(result.indexOf('Live reload server started on port: 35729') !== -1, 'live reload server should have been started on port 35729.');
|
||||
test.ok(result.indexOf('Live reload server started on port: 1337') !== -1, 'live reload server should have been started on port 35729.');
|
||||
test.ok(result.indexOf('Live reloading lib/one.js...') !== -1, 'live reload should have triggered on lib/one.js');
|
||||
resultData = JSON.parse(resultData);
|
||||
test.equal(resultData.tinylr, 'Welcome', 'tinylr server should have welcomed you.');
|
||||
|
Loading…
Reference in New Issue
Block a user