Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Livereload stream #118

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

emilbayes
Copy link

I realise this might not be something you're after, but maybe we can find common ground and have a feature that leaves more flexibility.

I want to bundle livereload on the fly with browserify as I've got some extra plugins that go with the stock version. Allowing one to pass a function that returns a stream was the least invasive solution I could come up with, that was also easy to code. I don't know if you have plans for a similar feature, but implemented differently? I'd be open to do the work, if we can find a solution that everyone is happy with.

This PR should be semver minor, as it preserves the existing API but also checks for opts.livereload being a function.

@mklabs
Copy link
Owner

mklabs commented Nov 10, 2016

Hi @emilbayes

I can't review and test today, but will give it a try tomorrow. Thanks for your PR, from a first view, it looks very good.

@emilbayes
Copy link
Author

No worries. The PR includes test too btw

@mklabs
Copy link
Owner

mklabs commented Nov 14, 2016

I quickly reviewed your PR. I'll probably merge later today, thanks for including all these tests as well.

Copy link
Owner

@mklabs mklabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overal, great PR. I requested some minor changes if you don't mind changing a bit your code, mainly to de-duplicate the tests.

import listen from './helpers/listen';
import {PassThrough} from 'stream';

describe('tiny-lr', () => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change the description to something like tiny-lr custom livereload to differentiate it from the other tests in the test output ?

return s;
}
}));

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the below tests, except maybe one GET /livereload.js, are copy-pasted from server.js. Can you try to refactor these two files to use a function passed to the parent describe in order to not duplicate these tests ?

Something like:

describe('tiny-lr custom livereload', () => {
  before(...)

  testLR(this);

  // divergent tests here, mainly GET /livereload.js
});

with testLR including all common tests from these two files. and using a param like context to map the this passed as a parameter.

lib/server.js Outdated
class Server extends events.EventEmitter {
constructor (options = {}) {
super();

this.options = options;

options.livereload = options.livereload || require.resolve('livereload-js/dist/livereload.js');
options.livereload = typeof options.livereload === 'string'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put ? ... at the end of the line instead of line breaking before ? ?

options.livereload = typeof options.livereload === 'string' ? wrapStream(options.livereload)
  : typeof options.livereload === 'function' ? options.livereload
  : wrapStream(require.resolve('livereload-js/dist/livereload.js'));

@emilbayes
Copy link
Author

Sorry for the late reply. The requested changes have been made 😄

@emilbayes
Copy link
Author

@mklabs Ping :)

@emilbayes
Copy link
Author

@mklabs Any further changes I need to do?

@elwayman02
Copy link
Collaborator

@emilbayes it looks like you have some merge conflicts to resolve, but I'm happy to take care of merging this into our upcoming release if you can update the PR! Sorry for the extremely slow response. <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants