Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated generated html to point to bundle url; #90

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions bin/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var path = require('path');
var prelude = fs.readFileSync(__dirname + '/../bundle/prelude.js', 'utf8');

var bundle, launch;
var bundleId = Math.floor(Math.pow(16,8)*Math.random()).toString(16);
var scripts = [];
var htmlQueue = [];
var pending = 4;
Expand Down Expand Up @@ -61,7 +62,6 @@ if ((process.stdin.isTTY || argv._.length) && argv._[0] !== '-') {
);
return;
}
var bundleId = Math.floor(Math.pow(16,8)*Math.random()).toString(16);

if (pkg.testling.preprocess) {
pending += 1;
Expand Down Expand Up @@ -160,6 +160,10 @@ var server = http.createServer(function (req, res) {
res.setHeader('content-type', 'text/html');
getHTML(function (html) { res.end(html) });
}
else if (u.replace(/\/$/, '') === '/__testling/' + bundleId + '.js') {
res.setHeader('content-type', 'application/javascript');
res.end(bundle);
}
else if (u.split('/')[1] === '__testling') {
req.url = req.url.replace(/^\/__testling/, '');
ecstatic(req, res);
Expand Down Expand Up @@ -313,7 +317,7 @@ function getHTML (cb) {
+ ent.encode(s) + '"></script>'
;
}).join('\n')
+ '<script>' + bundle + '</script>'
+ '<script src="/__testling/' + bundleId + '.js"></script>'
+ after
+ '</body></html>'
);
Expand Down