Comparing version 0.5.0 to 1.0.0
23
index.js
@@ -0,14 +1,21 @@ | ||
const {format} = require("path") | ||
const Mocha = require("mocha") | ||
module.exports = function () { | ||
this.mocha = function (opts) { | ||
module.exports = { | ||
name: "mocha", | ||
every: false, | ||
* func(files, opts) { | ||
const mocha = new Mocha(opts) | ||
return new Promise((resolve, reject) => { | ||
this.unwrap((files) => { | ||
files.forEach(f => mocha.addFile(f)) | ||
mocha.run((failures) => failures > 0 | ||
? reject(failures + " error(s).") : resolve()) | ||
}) | ||
for (const file of files) { | ||
mocha.addFile( format(file) ) | ||
} | ||
mocha.run(errors => { | ||
if (errors > 0) { | ||
return this.emit("plugin_error", { | ||
error: `${errors} error(s).`, | ||
plugin: "fly-mocha" | ||
}) | ||
} | ||
}) | ||
} | ||
} |
{ | ||
"name": "fly-mocha", | ||
"version": "0.5.0", | ||
"version": "1.0.0", | ||
"description": "Mocha plugin for Fly", | ||
@@ -9,9 +9,3 @@ "license": "MIT", | ||
"scripts": { | ||
"lint": "eslint *.js", | ||
"setup": "npm i && npm test", | ||
"spec": "npm run test | tspec", | ||
"test": "npm run lint && npm run test-harmony", | ||
"build": "echo No build task specified.", | ||
"deploy": "npm run test && git push origin master && npm publish", | ||
"test-harmony": "node test-harmony" | ||
"test": "eslint *.js && tape test/*.js | tap-spec" | ||
}, | ||
@@ -30,10 +24,10 @@ "author": "Jorge Bucaran", | ||
"devDependencies": { | ||
"fly-util": "^4.0.1", | ||
"eslint": "^2.7.0", | ||
"tap-spec": "^4.0.2", | ||
"eslint": "^3.14.1", | ||
"fly": "^2.0.0", | ||
"fly-clear": "^1.0.0", | ||
"tap-spec": "^4.1.1", | ||
"tape": "^4.0.0" | ||
}, | ||
"engines": { | ||
"iojs": ">= 1.0.0", | ||
"node": ">= 0.11.0" | ||
"node": ">= 6" | ||
}, | ||
@@ -40,0 +34,0 @@ "keywords": [ |
@@ -46,12 +46,12 @@ <div align="center"> | ||
[fly]: https://www.github.com/flyjs/fly | ||
[fly-badge]: https://img.shields.io/badge/fly-JS-05B3E1.svg?style=flat-square | ||
[mit-badge]: https://img.shields.io/badge/license-MIT-444444.svg?style=flat-square | ||
[fly-badge]: https://img.shields.io/badge/fly-JS-05B3E1.svg?style=flat-square&maxAge=2592000 | ||
[mit-badge]: https://img.shields.io/badge/license-MIT-444444.svg?style=flat-square&maxAge=2592000 | ||
[npm-pkg-link]: https://www.npmjs.org/package/fly-mocha | ||
[npm-ver-link]: https://img.shields.io/npm/v/fly-mocha.svg?style=flat-square | ||
[dl-badge]: http://img.shields.io/npm/dm/fly-mocha.svg?style=flat-square | ||
[npm-ver-link]: https://img.shields.io/npm/v/fly-mocha.svg?style=flat-square&maxAge=2592000 | ||
[dl-badge]: http://img.shields.io/npm/dm/fly-mocha.svg?style=flat-square&maxAge=2592000 | ||
[travis-link]: https://travis-ci.org/flyjs/fly-mocha | ||
[travis-badge]: http://img.shields.io/travis/flyjs/fly-mocha.svg?style=flat-square | ||
[travis-badge]: http://img.shields.io/travis/flyjs/fly-mocha.svg?style=flat-square&maxAge=2592000 | ||
[david-link]: https://david-dm.org/flyjs/fly-mocha | ||
[david-badge]: https://img.shields.io/david/flyjs/fly-mocha.svg?style=flat-square | ||
[david-dev-link]: https://david-dm.org/flyjs/fly-mocha#info=devDependencies&view=table | ||
[david-dev-badge]: https://img.shields.io/david/dev/flyjs/fly-mocha.svg?style=flat-square | ||
[david-badge]: https://img.shields.io/david/flyjs/fly-mocha.svg?style=flat-square&maxAge=2592000 | ||
[david-dev-link]: https://david-dm.org/flyjs/fly-mocha?type=dev | ||
[david-dev-badge]: https://img.shields.io/david/dev/flyjs/fly-mocha.svg?style=flat-square&maxAge=2592000 |
@@ -1,33 +0,29 @@ | ||
const test = require("tape").test | ||
const join = require("path").join | ||
const bind = require("fly-util").bind | ||
const state = { | ||
pass: { | ||
msg: "pass spec", | ||
spec: [join("test", "spec", "pass.js")] | ||
}, | ||
fail: { | ||
msg: "fail spec", | ||
spec: [join("test", "spec", "fail.js")] | ||
} | ||
} | ||
const unwrap = function (f) { f(this.spec) } | ||
const {join} = require("path") | ||
const test = require("tape") | ||
const Fly = require("fly") | ||
const dir = join(__dirname, "spec") | ||
test("fly-mocha", function (t) { | ||
t.plan(3) | ||
t.plan(5) | ||
const fly = {} | ||
require(bind("../")).call(fly) | ||
const fly = new Fly({ | ||
plugins: [require("../")], | ||
tasks: { | ||
* foo(f) { | ||
f.emit = (str, obj) => { | ||
t.equal(str, "plugin_error", "emits `plugin_error` on errors") | ||
t.true(/1/.test(obj.error), "emits with # of errors") | ||
} | ||
yield f.source(`${dir}/pass.js`).mocha() | ||
t.pass("pass spec") | ||
yield f.source(`${dir}/fail.js`).mocha() | ||
t.pass("fail spec") | ||
} | ||
} | ||
}) | ||
t.ok(fly.mocha !== undefined, "inject mocha in fly instance") | ||
t.true("mocha" in fly.plugins, "attach mocha() to fly") | ||
fly.unwrap = unwrap.bind(state.pass) | ||
fly.mocha() | ||
.then(() => t.ok(true, state.pass.msg)) | ||
.catch(() => t.ok(false, state.pass.msg)) | ||
fly.unwrap = unwrap.bind(state.fail) | ||
fly.mocha() | ||
.then(() => t.ok(false, state.fail.msg)) | ||
.catch(() => t.ok(true, state.fail.msg)) | ||
fly.start("foo") | ||
}) |
Sorry, the diff of this file is not supported yet
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
44042
1
1
0
5
69