Skip to content
Permalink
Browse files

Add bundler

The bundler packages Cucumber.js to be used in web browsers.
  • Loading branch information
jbpros committed Sep 10, 2012
1 parent a5a7f19 commit 716b284a05ad044bbf0fb58ca48a6f1a85423111
Showing with 37 additions and 14 deletions.
  1. +27 −0 bundler.js
  2. +2 −2 example/example.js
  3. +7 −11 example/server.js
  4. +1 −1 package.json
@@ -0,0 +1,27 @@
var browserify = require('browserify');

var Bundler = function () {
var requires = [
__dirname + '/node_modules/cucumber-html'
];

var self = browserify({
mount: '/cucumber.js',
require: requires,
ignore: ['./cucumber/cli', 'connect']
});

self.addEntry('underscore.js', {dirname: __dirname+"/node_modules/underscore", target: "/node_modules/underscore"});
self.addEntry('lib/gherkin.js', {dirname: __dirname+"/node_modules/gherkin", target: "/node_modules/gherkin"});
self.addEntry('lib/cucumber.js', {dirname: __dirname, target: "/cucumber"});
self.addEntry('lib/gherkin/lexer/en.js', {dirname: __dirname+"/node_modules/gherkin", target: "/node_modules/gherkin/lexer/en"});

self.prepend('(function(context) {');
if (process.env.DEBUG_LEVEL)
self.append("context.cucumberRequire = require;\n");
self.append("context.Cucumber = require('/cucumber');\ncontext.CucumberHTML = require('cucumber-html/src/main/resources/cucumber/formatter/formatter');\n})(window);");

return self;
};

module.exports = Bundler;
@@ -1,6 +1,6 @@
(function($) {
var CucumberHTMLListener = function($root) {
var CucumberHTML = require('cucumber-html');
var CucumberHTML = window.CucumberHTML;
var formatter = new CucumberHTML.DOMFormatter($root);

formatter.uri('report.feature');
@@ -70,7 +70,7 @@
};

function runFeature() {
var Cucumber = require('./lib/cucumber');
var Cucumber = window.Cucumber;
var supportCode;
var output = $('#output');
var errors = $('#errors');
@@ -1,16 +1,12 @@
var connect = require('connect');
var server = connect.createServer();
var browserify = require('browserify');

var port = process.env.PORT || 9797;
var cukeBundle = browserify({
mount: '/cucumber.js',
require: ['cucumber-html', './lib/cucumber', 'gherkin/lib/gherkin/lexer/en'],
ignore: ['./cucumber/cli', 'connect']
});
var connect = require('connect');
var server = connect.createServer();
var port = process.env.PORT || 9797;
var Bundler = require('../bundler');

server.use(connect.static(__dirname));
server.use(cukeBundle);

var bundler = Bundler();
server.use(bundler);
server.listen(port);

console.log('Accepting connections on port ' + port + '...');
@@ -44,7 +44,7 @@
"gherkin": "2.11.1",
"jasmine-node": "1.0.26",
"connect": "2.3.2",
"browserify": "1.13.2",
"browserify": "1.15.5",
"nopt": "1.0.10",
"underscore": "1.3.3",
"rimraf": "2.0.2",

0 comments on commit 716b284

Please sign in to comment.
You can’t perform that action at this time.