Produced by Araxis Merge on 10/24/2017 6:38:26 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | CHAMP_VA1.zip\CHAMP_VA1\node_modules\gulp-webserver\node_modules\tiny-lr | readme.md | Mon Oct 16 21:06:50 2017 UTC |
| 2 | CHAMP_VA1.zip\CHAMP_VA1\node_modules\gulp-webserver\node_modules\tiny-lr | readme.md | Mon Oct 23 19:49:05 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 10 | 584 |
| Changed | 9 | 18 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | # tiny-lr [](https: //travis-c i.org/mkla bs/tiny-lr ) | |
| 2 | ||
| 3 | This scrip t manages a tiny [Li veReload]( http://liv ereload.co m/) server | |
| 4 | implementa tion. | |
| 5 | ||
| 6 | [](http s://nodei. co/npm/tin y-lr/) | |
| 7 | ||
| 8 | It exposes an HTTP s erver and express mi ddleware, with a ver y basic RE ST | |
| 9 | Api to not ify the se rver of a particular change. | |
| 10 | ||
| 11 | It doesn't have any watch abil ity, it mu st be done at the bu ild proces s or | |
| 12 | applicatio n level. | |
| 13 | ||
| 14 | Instead, i t exposes a very sim ple API to notify th e server t hat some | |
| 15 | changes ha ve been ma de, then b roadcasted to every livereload client | |
| 16 | connected. | |
| 17 | ||
| 18 | # noti fy a singl e change | |
| 19 | curl http: //localhos t: PORT /changed?f iles=style .css | |
| 20 | ||
| 21 | # noti fy using a longer pa th | |
| 22 | curl http: //localhos t: PORT /changed?f iles=js/ap p.js | |
| 23 | ||
| 24 | # noti fy multipl e changes, comma or space deli mited | |
| 25 | curl http: //localhos t: PORT /changed?f iles=index .html,styl e.css,docs /docco.css | |
| 26 | ||
| 27 | Or you can bulk the informatio n into a P OST reques t, with bo dy as a JS ON array o f files. | |
| 28 | ||
| 29 | curl -X PO ST http:// localhost: PORT /changed - d '{ "file s": ["styl e.css", "a pp.js"] }' | |
| 30 | ||
| 31 | # from a JSON fi le | |
| 32 | node - pe 'JSON.s tringify({ files: [" some.css", "files.cs s"] })' > files.json | |
| 33 | curl -X PO ST -d @fil es.json ht tp://local host: PORT | |
| 34 | ||
| 35 | As for the livereloa d client, you need t o install the browse r extensio n: | |
| 36 | http://fee dback.live reload.com /knowledge base/artic les/86242- how-do-i-i nstall-and -use-the-b rowser-ext ensions- | |
| 37 | (**note**: you need to listen on port PORT to be abl e to use w ith your | |
| 38 | brower ext ension) | |
| 39 | ||
| 40 | or add the livereloa d script t ag manuall y: | |
| 41 | http://fee dback.live reload.com /knowledge base/artic les/86180- how-do-i-a dd-the-scr ipt-tag-ma nually- | |
| 42 | (and here you can ch oose whate ver port y ou want) | |
| 43 | ||
| 44 | ## Integra tion | |
| 45 | ||
| 46 | The best w ay to inte grate the runner in your workf low is to add it as a `reload` | |
| 47 | step withi n your bui ld tool. | |
| 48 | ||
| 49 | ```js | |
| 50 | var tinylr = require ('tiny-lr' ); | |
| 51 | ||
| 52 | // standar d LiveRelo ad port | |
| 53 | var port = PORT ; | |
| 54 | ||
| 55 | // tinylr( opts) => n ew tinylr. Server(opt s); | |
| 56 | tinylr().l isten(port , function () { | |
| 57 | console. log('... L istening o n %s ...', port); | |
| 58 | }) | |
| 59 | ``` | |
| 60 | ||
| 61 | You can de fine your own route and listen for speci fic reques t: | |
| 62 | ||
| 63 | ```js | |
| 64 | var server = tinylr( ); | |
| 65 | ||
| 66 | server.on( 'GET /mypl ace', func tion(req, res) { | |
| 67 | res.writ e('Mine'); | |
| 68 | res.end( ); | |
| 69 | }) | |
| 70 | ``` | |
| 71 | ||
| 72 | And stop t he server manually: | |
| 73 | ||
| 74 | ```js | |
| 75 | server.clo se(); | |
| 76 | ``` | |
| 77 | ||
| 78 | This will close any websocket connection establish ed and emi t a close event. | |
| 79 | ||
| 80 | ### Middle ware | |
| 81 | ||
| 82 | To use as a connect / express middleware , tiny-lr needs quer y / | |
| 83 | bodyParser middlewar es prior i n the stac k (to hand le POST re quests) | |
| 84 | ||
| 85 | Any handle d requests ends at t he tinylr level, not found and errors ar e | |
| 86 | nexted to the rest o f the stac k. | |
| 87 | ||
| 88 | ```js | |
| 89 | var port = process.e nv.LR_PORT || proces s.env.PORT || PORT ; | |
| 90 | ||
| 91 | var path = requir e('path'); | |
| 92 | var expres s = requir e('express '); | |
| 93 | var tinylr = requir e('tiny-lr '); | |
| 94 | var body = requir e('body-pa rser'); | |
| 95 | ||
| 96 | var app = express(); | |
| 97 | ||
| 98 | // This bi nds both e xpress app and tinyl r on the s ame port | |
| 99 | ||
| 100 | ||
| 101 | app | |
| 102 | .use(bod y()) | |
| 103 | .use(tin ylr.middle ware({ app : app })) | |
| 104 | .use(exp ress.stati c(path.res olve('./') )) | |
| 105 | .listen( port, func tion() { | |
| 106 | consol e.log('lis tening on %d', port) ; | |
| 107 | }); | |
| 108 | ``` | |
| 109 | ||
| 110 | The port y ou listen on is impo rtant, and tinylr sh ould **alw ays** list en on | |
| 111 | the LiveRe load stand ard one: ` PORT `. Otherwi se, you wo n't be abl e to rely | |
| 112 | on the bro wser exten sions, tho ugh you ca n still us e the manu al snippet | |
| 113 | approach. | |
| 114 | ||
| 115 | You can al so start t wo differe nt servers , one on y our app po rt, the | |
| 116 | other list ening on t he LiveRel oad port. | |
| 117 | ||
| 118 | ### Using grunt | |
| 119 | ||
| 120 | Head over to [https: //github.c om/gruntjs /grunt-con trib-watch ](https:// github.com /gruntjs/g runt-contr ib-watch#l ive-reload ing) | |
| 121 | ||
| 122 | ### Using make | |
| 123 | ||
| 124 | See [make- livereload ](https:// github.com /mklabs/ma ke-liverel oad) repo. | |
| 125 | ||
| 126 | ### Using gulp | |
| 127 | ||
| 128 | See [gulp- livereload ](https:// github.com /vohof/gul p-liverelo ad) repo. | |
| 129 | ||
| 130 | ## Tests | |
| 131 | ||
| 132 | npm te st | |
| 133 | ||
| 134 | --- | |
| 135 | ||
| 136 | ||
| 137 | # TOC | |
| 138 | - [tiny -lr](#tiny -lr) | |
| 139 | - [GE T /](#tiny -lr-get-) | |
| 140 | - [GE T /changed ](#tiny-lr -get-chang ed) | |
| 141 | - [PO ST /change d](#tiny-l r-post-cha nged) | |
| 142 | - [GE T /liverel oad.js](#t iny-lr-get -livereloa djs) | |
| 143 | - [GE T /kill](# tiny-lr-ge t-kill) | |
| 144 | <a name="" /> | |
| 145 | ||
| 146 | <a name="t iny-lr" /> | |
| 147 | # tiny-lr | |
| 148 | accepts ws clients. | |
| 149 | ||
| 150 | ```js | |
| 151 | var url = parse(this .request.u rl); | |
| 152 | var server = this.ap p; | |
| 153 | ||
| 154 | var ws = t his.ws = n ew WebSock et('ws://' + url.hos t + '/live reload'); | |
| 155 | ||
| 156 | ws.onopen = function (event) { | |
| 157 | var hell o = { | |
| 158 | comman d: 'hello' , | |
| 159 | protoc ols: ['htt p://livere load.com/p rotocols/o fficial-7' ] | |
| 160 | }; | |
| 161 | ||
| 162 | ws.send( JSON.strin gify(hello )); | |
| 163 | }; | |
| 164 | ||
| 165 | ws.onmessa ge = funct ion(event) { | |
| 166 | assert.d eepEqual(e vent.data, JSON.stri ngify({ | |
| 167 | comman d: 'hello' , | |
| 168 | protoc ols: ['htt p://livere load.com/p rotocols/o fficial-7' ], | |
| 169 | server Name: 'tin y-lr' | |
| 170 | })); | |
| 171 | ||
| 172 | assert.o k(Object.k eys(server .clients). length); | |
| 173 | done(); | |
| 174 | }; | |
| 175 | ``` | |
| 176 | ||
| 177 | properly c leans up e stablished connectio n on exit. | |
| 178 | ||
| 179 | ```js | |
| 180 | var ws = t his.ws; | |
| 181 | ||
| 182 | ws.onclose = done.bi nd(null, n ull); | |
| 183 | ||
| 184 | request(th is.server) | |
| 185 | .get('/k ill') | |
| 186 | .expect( 200, funct ion() { | |
| 187 | consol e.log('ser ver shutdo wn'); | |
| 188 | }); | |
| 189 | ``` | |
| 190 | ||
| 191 | <a name="t iny-lr" /> | |
| 192 | # tiny-lr | |
| 193 | <a name="t iny-lr-get -" /> | |
| 194 | ## GET / | |
| 195 | respond wi th nothing , but resp ond. | |
| 196 | ||
| 197 | ```js | |
| 198 | request(th is.server) | |
| 199 | .get('/' ) | |
| 200 | .expect( 'Content-T ype', /jso n/) | |
| 201 | .expect( '{"tinylr" :"Welcome" ,"version" :"0.0.1"}' ) | |
| 202 | .expect( 200, done) ; | |
| 203 | ``` | |
| 204 | ||
| 205 | unknown ro ute respon d with pro per 404 an d error me ssage. | |
| 206 | ||
| 207 | ```js | |
| 208 | request(th is.server) | |
| 209 | .get('/w hatev') | |
| 210 | .expect( 'Content-T ype', /jso n/) | |
| 211 | .expect( '{"error": "not_found ","reason" :"no such route"}') | |
| 212 | .expect( 404, done) ; | |
| 213 | ``` | |
| 214 | ||
| 215 | <a name="t iny-lr-get -changed" /> | |
| 216 | ## GET /ch anged | |
| 217 | with no cl ients, no files. | |
| 218 | ||
| 219 | ```js | |
| 220 | request(th is.server) | |
| 221 | .get('/c hanged') | |
| 222 | .expect( 'Content-T ype', /jso n/) | |
| 223 | .expect( /"clients" :\[\]/) | |
| 224 | .expect( /"files":\ [\]/) | |
| 225 | .expect( 200, done) ; | |
| 226 | ``` | |
| 227 | ||
| 228 | with no cl ients, som e files. | |
| 229 | ||
| 230 | ```js | |
| 231 | request(th is.server) | |
| 232 | .get('/c hanged?fil es=gonna.c ss,test.cs s,it.css') | |
| 233 | .expect( 'Content-T ype', /jso n/) | |
| 234 | .expect( '{"clients ":[],"file s":["gonna .css","tes t.css","it .css"]}') | |
| 235 | .expect( 200, done) ; | |
| 236 | ``` | |
| 237 | ||
| 238 | <a name="t iny-lr-pos t-changed" /> | |
| 239 | ## POST /c hanged | |
| 240 | with no cl ients, no files. | |
| 241 | ||
| 242 | ```js | |
| 243 | request(th is.server) | |
| 244 | .post('/ changed') | |
| 245 | .expect( 'Content-T ype', /jso n/) | |
| 246 | .expect( /"clients" :\[\]/) | |
| 247 | .expect( /"files":\ [\]/) | |
| 248 | .expect( 200, done) ; | |
| 249 | ``` | |
| 250 | ||
| 251 | with no cl ients, som e files. | |
| 252 | ||
| 253 | ```js | |
| 254 | var data = { clients : [], file s: ['cat.c ss', 'sed. css', 'ack .js'] }; | |
| 255 | ||
| 256 | request(th is.server) | |
| 257 | .post('/ changed') | |
| 258 | .send({ files: dat a.files }) | |
| 259 | .expect( 'Content-T ype', /jso n/) | |
| 260 | .expect( JSON.strin gify(data) ) | |
| 261 | .expect( 200, done) ; | |
| 262 | ``` | |
| 263 | ||
| 264 | <a name="t iny-lr-get -livereloa djs" /> | |
| 265 | ## GET /li vereload.j s | |
| 266 | respond wi th liverel oad script . | |
| 267 | ||
| 268 | ```js | |
| 269 | request(th is.server) | |
| 270 | .get('/l ivereload. js') | |
| 271 | .expect( /LiveReloa d/) | |
| 272 | .expect( 200, done) ; | |
| 273 | ``` | |
| 274 | ||
| 275 | <a name="t iny-lr-get -kill" /> | |
| 276 | ## GET /ki ll | |
| 277 | shutdown t he server. | |
| 278 | ||
| 279 | ```js | |
| 280 | var server = this.se rver; | |
| 281 | request(se rver) | |
| 282 | .get('/k ill') | |
| 283 | .expect( 200, funct ion(err) { | |
| 284 | if(err ) return d one(err); | |
| 285 | assert .ok(!serve r._handle) ; | |
| 286 | done() ; | |
| 287 | }); | |
| 288 | ``` | |
| 289 | ||
| 290 | ## Thanks! | |
| 291 | ||
| 292 | - Tiny-lr is a [Live Reload](ht tp://liver eload.com/ ) implemen tation. Th ey | |
| 293 | really m ade fronte nd editing better fo r a lot of us. They have a | |
| 294 | [LiveRel oad App on the Mac A pp Store]( https://it unes.apple .com/us/ap p/liverelo ad/id48289 8991) | |
| 295 | you migh t want to check out. | |
| 296 | ||
| 297 | - To all [ contributo rs](https: //github.c om/mklabs/ tiny-lr/gr aphs/contr ibutors) | |
| 298 | ||
| 299 | - [@FGRibr eau](https ://github. com/FGRibr eau) / [pi d.js | |
| 300 | gist](ht tps://gist .github.co m/1846952) ) for the background friendly | |
| 301 | bin wrappe r, used in [make-liv ereload](h ttps://git hub.com/mk labs/make- livereload ) |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.