cukestall
Advanced tools
Comparing version 0.0.1 to 0.0.2
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
2
131934
4
682
64
+ Addedbrowserify@1.15.5
+ Addedcucumber@0.2.21
+ Added@xmldom/xmldom@0.8.10(transitive)
+ AddedBase64@0.1.4(transitive)
+ Addedabbrev@1.1.1(transitive)
+ Addedbase64-js@0.0.2(transitive)
+ Addedbops@0.0.6(transitive)
+ Addedbrowserify@1.15.5(transitive)
+ Addedbuffer-browserify@0.0.5(transitive)
+ Addedcoffee-script@1.12.71.3.3(transitive)
+ Addedcommondir@0.0.2(transitive)
+ Addedconcat-stream@1.0.1(transitive)
+ Addedconnect@2.3.2(transitive)
+ Addedcookie@0.0.3(transitive)
+ Addedcrc@0.2.0(transitive)
+ Addedcrypto-browserify@0.4.0(transitive)
+ Addedcucumber@0.2.21(transitive)
+ Addedcucumber-html@0.2.0(transitive)
+ Addeddebug@4.3.5(transitive)
+ Addeddeputy@0.0.4(transitive)
+ Addeddetective@0.2.1(transitive)
+ Addedesprima@0.9.9(transitive)
+ Addedformidable@1.0.9(transitive)
+ Addedgherkin@2.11.1(transitive)
+ Addedgraceful-fs@1.1.14(transitive)
+ Addedhttp-browserify@0.1.14(transitive)
+ Addedindexof@0.0.1(transitive)
+ Addedjasmine-node@1.0.26(transitive)
+ Addedjasmine-reporters@2.5.2(transitive)
+ Addedmkdirp@0.3.31.0.4(transitive)
+ Addedms@2.1.2(transitive)
+ Addednopt@1.0.10(transitive)
+ Addednub@0.0.0(transitive)
+ Addedoptimist@0.3.7(transitive)
+ Addedrequirejs@2.3.6(transitive)
+ Addedresolve@0.2.8(transitive)
+ Addedrimraf@2.0.2(transitive)
+ Addedsyntax-error@0.0.1(transitive)
+ Addedto-utf8@0.0.1(transitive)
+ Addedunderscore@1.3.3(transitive)
+ Addedvm-browserify@0.0.4(transitive)
+ Addedwalkdir@0.0.4(transitive)
+ Addedwordwrap@0.0.3(transitive)
- Removedformidable@1.0.17(transitive)