Created
July 20, 2016 23:24
-
-
Save damieng/81e1db0aa109fa041c35628481b93506 to your computer and use it in GitHub Desktop.
Grunt http server in Coffeescript
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
http = require('http') | |
module.exports = (grunt) -> | |
grunt.registerTask 'local-crash-reporter', 'Start a local crash reporter server.', -> | |
PORT = 1127 | |
done = this.async() | |
server = http.createServer (request, response) -> | |
if request.method is 'POST' | |
body = [] | |
request.on 'data', (chunk) -> | |
body.push(chunk) | |
request.on 'end', -> | |
grunt.log.write "\nPOST to #{request.url} with BODY of;\n" | |
grunt.log.write Buffer.concat(body).toString() | |
grunt.log.write "\n" | |
response.end() | |
server.listen PORT, -> | |
grunt.log.write "Local crash reporter listening on http://localhost:#{PORT}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment