Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

blow

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blow - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

84

blow.js

@@ -46,4 +46,7 @@ /**

//
var indexFile = generateIndex(map, settings.style);
// Standart output
var base = preGenerate(settings.index, settings.style);
//Generate pages
var indexFile = generateIndex(base, map);
app.route('/').html(indexFile);

@@ -53,3 +56,3 @@

Object.keys(map).forEach(function (relative) {
var content = generateTest(relative, settings.style);
var content = generateTest(base, relative);
app.route(relative).html(content);

@@ -64,18 +67,51 @@ });

// Standart output
var base = domstream( fs.readFileSync( path.resolve(path.dirname(module.filename), 'index.html') ) );
function preGenerate(file, style) {
var base = domstream(fs.readFileSync(file)).live(true);
var head = base.find().only().elem('head').toValue();
if (!head) throw new Error('a <head> tag must exist');
var body = base.find().only().elem('body').toValue();
if (!body) throw new Error('a <body> tag must exist');
// insert meta tag
var meta = head.find().only().elem('meta').attr('charset').toValue();
if (meta === false) {
head.insert('afterbegin', '<meta charset="utf8">');
meta = head.find().only().elem('meta').attr('charset').toValue();
}
// insert title tag
var title = head.find().only().elem('title').toValue();
if (title === false) {
meta.insert('afterend', '<title></title>');
title = head.find().only().elem('title').toValue();
}
// insert framework files
title.insert('afterend',
'<link rel="stylesheet" href="/file/mocha.css">' +
'<script src="/file/chai.js"></script>' +
'<script src="/file/mocha.js"></script>' +
'<script>mocha.setup("' + style + '")</script>' +
'<script>window.onload = function () { mocha.run() };</script>');
// insert framework container
var container = body.find().only().attr('id', 'mocha').toValue();
if (container === false) {
body.append('<div id="mocha"></div>');
}
return base.live(false);
}
// generate the master testsuite
function generateIndex(files, style) {
function generateIndex(base, files) {
var document = base.copy();
// modify title
var title = document.find().only().elem('title').toValue();
title.setContent('Mocha Tests - all');
// add testcases
var head = document.find().only().elem('head').toValue();
// set mocha style
head.append('<script>mocha.setup("' + style + '")</script>');
// set title
head.find()
.only().elem('title').toValue()
.setContent('Mocha Tests - all');

@@ -87,5 +123,2 @@ // bind testcases

// bind mocha runner
head.append('<script> window.onload = function () { mocha.run() }; </script>');
return document.content;

@@ -95,22 +128,15 @@ }

// generate individual testcases
function generateTest(file, style) {
function generateTest(base, file) {
var document = base.copy();
var head = document.find().only().elem('head').toValue();
// modify title
var title = document.find().only().elem('title').toValue();
title.setContent('Mocha Tests - ' + file);
head.find()
.only().elem('title').toValue()
.setContent('Mocha Tests - ' + file);
// add testcases
var head = document.find().only().elem('head').toValue();
// set mocha style
head.append('<script>mocha.setup("' + style + '")</script>');
// bind testcases
head.append('<script src="/test' + file + '"></script>');
// bind mocha runner
head.append('<script> window.onload = function () { mocha.run() }; </script>');
return document.content;
}
{
"name": "blow",
"description": "Simple browser boilerplate for the test framework: mocha",
"version": "0.1.4",
"version": "0.1.5",
"author": "Andreas Madsen <amwebdk@gmail.com>",

@@ -21,3 +21,3 @@ "bin": { "blow": "./bin/blow" },

"chai": "1.1.x",
"domstream": "0.3.x",
"domstream": "0.4.x",
"tako": "0.3.x"

@@ -24,0 +24,0 @@ },

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc