Socket
Socket
Sign inDemoInstall

cukestall

Package Overview
Dependencies
62
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.1 to 0.0.2

public/cukestall/images/logo.png

96

cukestall.js
var BACKDOOR_NAME_REGEXP = /[^\/]+$/;
var DEFAULT_MOUNT_ENDPOINT = '/cukestall';
var fs = require('fs');
var express = require('express');
var fs = require('fs');
var path = require('path');
var express = require('express');
var browserify = require('browserify');
var Bundler = require('cucumber/bundler');
var DEFAULT_MOUNT_ENDPOINT = "/cukestall";
var CukeStall = {
runner: function cukes(options) {
runner: function runner(options) {
options = options || {};
options.backdoors = options.backdoors || {};
options.mountEndPoint = options.mountEndPoint || DEFAULT_MOUNT_ENDPOINT;
options.require = options.require || [];
var featurePaths = options.featurePaths;
var supportCodePaths = options.supportCodePaths;
var stepDefsPaths = options.stepDefsPaths;
var backdoors = options.backdoors || {};
var mountEndpoint = options.mountEndpoint || DEFAULT_MOUNT_ENDPOINT;
var bundler = Bundler();
var serveStatic = express.static(__dirname + '/public');
var serveStatic = express.static(__dirname + '/public')
var serveCukeStall = function serveCukeStall(req, res, next) {
if (req.path == options.mountEndPoint + '/javascripts/cucumber.js') {
res.setHeader('Content-Type', 'application/javascript');
res.end(bundler.bundle());
} else if (req.path == options.mountEndPoint + '/javascripts/cukestall.js') {
res.setHeader('Content-Type', 'application/javascript');
var supportCodeBundle = browserify();
supportCodeBundle.prepend('(function(context) {\n');
return function (req, res, next) {
var serveCukeStall = function serveCukeStall() {
if (req.url == mountEndpoint || req.url == mountEndpoint + '/') {
var features = [];
featurePaths.forEach(function (featurePath) {
features.push(fs.readFileSync(featurePath));
});
res.render(__dirname + '/views/index', {features: features, layout: 'layouts/application'});
} else if (req.url == mountEndpoint + '/blank') {
res.render(__dirname + '/views/blank', {layout: 'layouts/application'});
} else if (req.url == mountEndpoint + '/javascripts/stepdefs.js') {
res.setHeader('Content-Type', 'application/javascript');
res.write("window.supportCode = function () {\n");
supportCodePaths.forEach(function (supportCodePath) {
var supportCode = require(supportCodePath);
res.write('(' + supportCode.toString() + ').apply(this);\n');
});
res.write("\n};\n");
res.write("window.stepDefs = function () {\n");
stepDefsPaths.forEach(function (stepDefsPath) {
var stepDefs = require(stepDefsPath);
res.write('(' + stepDefs.toString() + ').apply(this);\n');
});
res.end("\n};\n");
supportCodeBundle.append("context.supportCode = function () {\n");
options.require.forEach(function(requirePath) {
normalizedPath = path.normalize(requirePath);
supportCodeBundle.addEntry(requirePath, {target: path.normalize(normalizedPath)});
supportCodeBundle.append("require('"+normalizedPath+"').call(this);");
});
supportCodeBundle.append("};\n");
if (process.env.DEBUG_LEVEL)
supportCodeBundle.append("context.cukestallRequire = require;\n");
supportCodeBundle.append("})(window);");
res.end(supportCodeBundle.bundle());
} else if (req.url == options.mountEndPoint || req.url == options.mountEndPoint + '/') {
var features = [];
options.features.forEach(function (feature) {
features.push(fs.readFileSync(feature));
});
res.render(__dirname + '/views/index.ejs', {features: features, layout: 'layouts/application'});
} else if (req.url == options.mountEndPoint + '/blank') {
res.render(__dirname + '/views/blank.ejs', {layout: 'layouts/application'});
} else {
var backdoorName = BACKDOOR_NAME_REGEXP.exec(req.url);
if (backdoorName != null && options.backdoors[backdoorName]) {
options.backdoors[backdoorName](req, res, next);
} else {
var backdoorName = BACKDOOR_NAME_REGEXP.exec(req.url);
if (backdoorName != null && backdoors[backdoorName]) {
backdoors[backdoorName](req, res, next);
} else {
next();
}
next();
}
};
serveStatic(req, res, serveCukeStall);
}
};
return function (req, res, next) {
serveStatic(req, res, function () {
serveCukeStall(req, res, next);
});
};
}
};
module.exports = CukeStall;
module.exports = CukeStall;

@@ -5,3 +5,3 @@ {

"description": "Cucumber.js in-browser runner",
"version": "0.0.1",
"version": "0.0.2",
"main": "./cukestall",

@@ -13,2 +13,4 @@ "repository": {

"dependencies": {
"cucumber": "0.2.21",
"browserify": "1.15.5",
"express": "2.5.9",

@@ -15,0 +17,0 @@ "ejs": "0.6.1"

@@ -136,3 +136,3 @@ (function($) {

var CucumberHTMLListener = function($root) {
var CucumberHTML = require('cucumber-html');
var CucumberHTML = window.CucumberHTML;
var formatter = new CucumberHTML.DOMFormatter($root);

@@ -220,7 +220,7 @@

function runFeature() {
var Cucumber = require('./cucumber');
var Cucumber = window.Cucumber;
var supportCode;
var output = $('#output');
var featureSource = $('script[type="text/x-gherkin"]').first().html();
var supportCode = function () { window.supportCode.call(this); window.stepDefs.call(this); };
var supportCode = function () { window.supportCode.call(this); };
var cucumber = Cucumber(featureSource, supportCode);

@@ -227,0 +227,0 @@ var $output = $('#output');

@@ -23,5 +23,4 @@ # CukeStall

app.use(CukeStall.runner({
featurePaths: [__dirname + '/features/my.feature'],
stepDefsPaths: [__dirname + '/features/step_definitions/stepdefs.js'],
supportCodePaths: [__dirname + '/features/support/cukestall.js']
features: [__dirname + '/features/my.feature'],
require: [__dirname + '/features/step_definitions/stepdefs.js', __dirname + '/features/support/cukestall.js']
}));

@@ -42,5 +41,4 @@

app.use(CukeStall.runner({
featurePaths: [__dirname + '/features/my.feature'],
stepDefsPaths: [__dirname + '/features/step_definitions/stepdefs.js'],
supportCodePaths: [__dirname + '/features/support/cukestall.js']
features: [__dirname + '/features/my.feature'],
require: [__dirname + '/features/step_definitions/stepdefs.js', __dirname + '/features/support/cukestall.js']
backdoors: {

@@ -47,0 +45,0 @@ reset_all: function (req, res, next) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc