forked from slab/quill
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move custom server to grunt connect task with custom middleware allows us to utilize the keepalive feature to fix code coverage generation
- Loading branch information
Showing
8 changed files
with
71 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/.build | ||
/coverage | ||
/.coverage | ||
/dist | ||
/lib | ||
/node_modules | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
.build | ||
.coverage | ||
.git | ||
.travis.yml | ||
_* | ||
bower.json | ||
*.log | ||
coverage | ||
examples | ||
grunt | ||
src | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
_ = require('lodash') | ||
coffeeify = require('coffeeify') | ||
fs = require('fs') | ||
harp = require('harp') | ||
stylus = require('stylus') | ||
watchify = require('watchify') | ||
|
||
|
||
bundle = (w) -> | ||
return w.bundle({ standalone: 'Quill' }) | ||
|
||
serve = (connect, req, res, next) -> | ||
watchers = connect.watchers | ||
switch req.url | ||
when '/quill.js' | ||
res.setHeader('Content-Type', 'application/javascript') | ||
bundle(watchers['src']).pipe(res) | ||
when '/test/quill.js' | ||
res.setHeader('Content-Type', 'application/javascript') | ||
bundle(watchers['test']).pipe(res) | ||
when '/quill.snow.css' | ||
res.setHeader('Content-Type', 'text/css') | ||
fs.readFile('./src/themes/snow/snow.styl', (err, data) -> | ||
s = stylus(data.toString()) | ||
s.include('./src/themes/snow') | ||
s.define('url', stylus.url()) | ||
s.render((err, css) -> | ||
res.write(css) | ||
res.end() | ||
) | ||
) | ||
else | ||
next() | ||
|
||
|
||
module.exports = (grunt) -> | ||
grunt.config('connect', | ||
options: | ||
onCreateServer: (server, connect, options) -> | ||
connect.watchers = _.reduce(['src', 'test'], (watchers, type) -> | ||
w = watchify("./#{type}/quill.coffee", { extensions: ['.js', '.coffee'] }) | ||
watchers[type] = w | ||
w.require('./.build/lodash.js', { expose: 'lodash' }) | ||
w.transform(coffeeify) | ||
w.on('update', bundle.bind(this, w)) | ||
bundle(w) if options.keepalive | ||
return watchers | ||
, {}) | ||
middleware: (connect, options, middlewares) -> | ||
middlewares.push(serve.bind(this, connect)) | ||
middlewares.push(harp.mount(__dirname + '/..')) | ||
return middlewares | ||
debug: true | ||
server: | ||
options: | ||
port: 9000 | ||
coverage: | ||
options: | ||
port: 9001 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.