convert to rollup build system

This commit is contained in:
Geoff Doty 2020-09-08 17:29:56 -05:00
parent 1a388656f2
commit ec4e087e90
4 changed files with 958 additions and 235 deletions

View File

@ -1,9 +1,25 @@
const gulp = require("gulp");
const minify = require("gulp-minify");
const strip = require("gulp-strip-comments");
const rollup = require("gulp-rollup-2").rollup;
gulp.task("default", function build() {
return gulp.src("./src/testit.js")
.pipe(rollup({
input: "./src/testit.js",
output: [
{
file: "testit.js",
name: "es",
format: "es"
},
{
file: "testit.umd.js",
name: "umd",
format: "umd"
},
]
}))
.pipe(strip({safe: true}))
.pipe(minify({ext: {min: ".min.js"}}))
.pipe(gulp.dest("dist"))

979
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
{
"name": "testit",
"version": "0.8.2",
"description": "a minimalistic testing library",
"version": "0.9.0",
"description": "minimalistic testing library",
"main": "src/testit.js",
"directories": {
"test": "test"
@ -15,6 +15,7 @@
"eslint": "^7.8.1",
"gulp": "^4.0.2",
"gulp-minify": "^3.1.0",
"gulp-rollup-2": "^1.1.0",
"gulp-strip-comments": "^2.5.2"
},
"repository": {

View File

@ -1,16 +1,6 @@
/*! Test.it v 0.8.0 | MIT | https://github.com/n2geoff/testit */
;(function (root, factory) {
"use strict";
// support browser & commonjs
if (typeof module === "object" && module.exports) {
module.exports = factory(root.test);
} else {
root.test = factory(root.test);
}
}(this, function () {
"use strict";
const test = {
/*! Test.it v 0.9.0 | MIT | https://github.com/n2geoff/testit */
const test = {
"log": console.log,
"_tests": {},
"run": function run(errors, next) {
// TODO: rewrite to allow a show errors flag (optional)
@ -19,7 +9,7 @@
errors = true;
}
let tests = this._tests;
let tests = this._tests || [];
// capture results
let failed = [];
let passed = [];
@ -48,8 +38,8 @@
fail: failed
});
} else {
console.log(...passed, ...failed);
console.log(`\n# tests ${failed.length + passed.length} pass ${passed.length} fail ${failed.length}`);
test.log(...passed, ...failed);
test.log(`\n# tests ${failed.length + passed.length} pass ${passed.length} fail ${failed.length}`);
return failed.length ? false : true;
}
@ -65,8 +55,8 @@
"a": (type) => { return test.expects(val).to.be.an(type); },
"an": (type) => {
if(['array'].indexOf(type) !== -1) {
if(val.constructor.name.toLowerCase() !== 'array') {
if(["array"].indexOf(type) !== -1) {
if(val.constructor.name.toLowerCase() !== "array") {
throw new Error(`expected ${typeof val} to be an ${type}`);
}
@ -99,7 +89,6 @@
}
};
}
};
};
return test;
}));
export default test;