grunt-browser-output
Advanced tools
Comparing version 0.1.0 to 1.0.0
@@ -1,6 +0,13 @@ | ||
(function(){ | ||
(function grunt_browser_output(ssl){ | ||
if (typeof ssl === 'undefined'){ | ||
var scripts= document.getElementsByTagName('script'); | ||
var path= scripts[scripts.length-1].src; | ||
var indexOfSsl = path.indexOf('ssl='); | ||
ssl = (indexOfSsl === -1 ? false : path.substr(indexOfSsl + 4,4) === 'true'); | ||
} | ||
var state = document.readyState; | ||
if(state !== 'interactive' && state !== 'complete') { | ||
setTimeout(arguments.callee, 100); | ||
setTimeout(grunt_browser_output.bind(this,ssl), 100); | ||
return; | ||
@@ -14,3 +21,5 @@ } | ||
var connection = new WebSocket('ws://localhost:37901'); | ||
var protocol = ssl ? 'wss' : 'ws'; | ||
var connection = new WebSocket(protocol + '://localhost:37901'); | ||
connection.onmessage = function(e){ | ||
@@ -17,0 +26,0 @@ var data = JSON.parse(e.data); |
@@ -0,0 +0,0 @@ /* |
{ | ||
"name": "grunt-browser-output", | ||
"version": "0.1.0", | ||
"version": "1.0.0", | ||
"description": "Redirect grunt output to the browser.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -35,3 +35,5 @@ # grunt-browser-output | ||
browser_output: { | ||
//no options currently, just need the empty target | ||
options: { //all options are optional | ||
port: 37901 //default is 37901 | ||
} | ||
}, | ||
@@ -52,3 +54,24 @@ }) | ||
### HTTPS/SSL | ||
If you run your site over HTTPS, you'll likely want to configure this task to also use HTTPS. Change the task config: | ||
```js | ||
grunt.initConfig({ | ||
browser_output: { | ||
options: { | ||
ssl: true, | ||
key: grunt.file.read('path/to/server.key'), | ||
cert: grunt.file.read('path/to/server.crt') | ||
} | ||
}, | ||
}) | ||
``` | ||
And in your index.html add put `?ssl=true` on the end of the client.js script tag: | ||
```html | ||
<script src="node_modules/grunt-browser-output/client.js?ssl=true"></script> | ||
``` | ||
## Release History | ||
- 3/13/2014 - v0.1.0 - Initial release. |
@@ -10,6 +10,26 @@ 'use strict'; | ||
var options = this.options({port:37901}); | ||
//start server | ||
var WebSocketServer = ws.Server; | ||
var wss = new WebSocketServer({port: 37901}); | ||
var wss; | ||
if (!options.ssl){ | ||
wss = new WebSocketServer({port: options.port}); | ||
} else { | ||
var processRequest = function (req, res) { | ||
res.writeHead(200, {'Content-Type': 'text/plain'}); | ||
res.end('Not implemented'); | ||
}; | ||
var app = require('https').createServer({ | ||
key: options.key, | ||
cert: options.cert | ||
},processRequest).listen(options.port); | ||
wss = new WebSocketServer({server:app}); | ||
console.log('STARTED IN SSL MODE'); | ||
} | ||
wss.broadcast = function(data) { | ||
@@ -16,0 +36,0 @@ for(var i in this.clients) { |
@@ -0,0 +0,0 @@ 'use strict'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
273374
243
0
76
1