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

Already on GitHub? Sign in to your account

Build Tweaks: Now builds on Windows, running "rake test" does npm and compiles clever #5

wants to merge 6 commits into


None yet
2 participants

I am adding some tweaks to python-livereload server and needed to insure I can reliably build/test livereload.js (on Windows) with extra logging built into it.

This is a set of patches geared for building and testing a bit easier (and now, finally, also allowing that on Windows.)

* rake now compiles only the files that changed (all the way though looking at version file)
* rake now tests (and also pulls needed modules through NPM) (and builds before testing)
* build's concatenation ordering logic is simplified to the bone, by:
    - switching to Ruby's built-in TSort for Topological Sort (dependency ordering)
    - replacing the Regex-based "replacement of require/exports" with "tiny fake require/exports" header. Modules now don't need to be changed during concatenation, just wrapped into self-exec function.

* !!!! tests changed from Expresso to Mocha !!!!!. Expresso does not install / work on Windows. I have no religious affiliation with either, and don't give an F which testing framework is there, as long as it works (on my, very major platform - Windows). I am sure there will be enough people over there who will like the switch.
* fixed a bug in test checking for wrong protocol string

Note, I did not commit the new /dist/livereload.js It's "almost" the same as the old one in structure and, per my tests (against python-livereload server), works the same. However, I don't know what extra functionality you have in Mac server/app, so did not want to push a commit replacing contents of /dist/ folder, until you feel good about this all.

dvdotsenko added some commits Sep 3, 2012

Removing node_modules folder +>> .gitignore
It's only needed for testing and future :test build point will import needed NodeJS modules.
Different platforms need different versions of jsdom anyway.
Tweaking module structure to allow faking 'require' in consolidated .js
Also adding fake require/exports implementation
using this we don't need to rewire joined modules. Just wrap them into self-execute and let them peruse the fake exports/require
Moving version ref into separate require module.
It's much easier to create the whole file at build, than Regexing around list of files.
updated Rakefile
* Changed dependency tree so that only changed files are compiled
* Changed how main modules are concatenated.
 - No more Regexing+string replacement. That's fricken dangerous.
 - Now each module is just wrapped into self-exec fn and they continue to use "require" and "exports"
 - a tiny (a douzen lines) "magic" implementation of require/exports is added to livereload.js
 - The module ordering logic is replaced by Ruby's built-in Topological Sort (TSort) function - whose task in life is to do DAG / Dependency Resolution done right.
Converting test from expresso to mocha
expresso would not install on my Windows machine.
mocha works on Windows (and new and shiny)

"If it does not work on Windows, it does not exist." :)

You could run as: mocha --ui exports --compilers coffee:coffee-script
but a :test task is also added to the Rakefile so you could just "rake test"
Protocol module now builds "all protocols" array. Connector module ju…
…st reuses the array. Simpler.

We still export all protocols separately so code can use them separately. Yet, In "hello" it makes no point whatsoever for connector to pick and choose.

Example of running "rake test" after altering 3 files:

c:\projects\python-livereload\livereload\livereload-js>\bin\ruby\bin\rake test
(in c:/projects/python-livereload/livereload/livereload-js)
coffee -c -b -o node_modules src/connector.coffee
coffee -c -b -o node_modules src/livereload.coffee
coffee -c -b -o node_modules src/protocol.coffee
CONCAT dist/livereload.js
mocha --ui exports --globals DOC_TYPE_START,DOC_TYPE_END --compilers coffee:coffee-script


15 tests complete (377ms)

andreyvit commented Jan 16, 2015

Hey, I'd love to merge this (especially the Mocha transition), just need to review it first. (Also, I've emailed you.)


andreyvit commented Jan 16, 2015

Okay, so your pull request in unmergable (different line endings), here's what I did instead:

  • converted tests to Mocha myself (and made sure they run)
  • converted the build process to Grunt and Browserify
  • I did not do anything about jsdom, let me know if it's still an issue these days

Does that suit your needs?

@andreyvit andreyvit closed this Jan 16, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment