now modularized, implements #11
This commit is contained in:
4
dist/mod02/index.d.ts
vendored
Normal file
4
dist/mod02/index.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/// <reference types="q" />
|
||||
import * as q from 'q';
|
||||
import { INpmtsConfig } from '../npmts.config';
|
||||
export declare let run: (configArg: INpmtsConfig) => q.Promise<INpmtsConfig>;
|
97
dist/mod02/index.js
vendored
Normal file
97
dist/mod02/index.js
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
"use strict";
|
||||
/* ------------------------------------------
|
||||
* This module tests the compiled TypeScript files
|
||||
* -------------------------------------------- */
|
||||
const plugins = require("./mod02.plugins");
|
||||
const paths = require("../npmts.paths");
|
||||
const q = require("q");
|
||||
const npmts_log_1 = require("../npmts.log");
|
||||
/**
|
||||
* runs mocha
|
||||
* @returns INpmtsConfig
|
||||
*/
|
||||
let mocha = function (configArg) {
|
||||
npmts_log_1.npmtsOra.text('Instrumentalizing and testing transpiled JS');
|
||||
npmts_log_1.npmtsOra.end(); // end npmtsOra for tests.
|
||||
let done = q.defer();
|
||||
plugins.gulp.src([plugins.path.join(paths.cwd, 'dist/*.js')])
|
||||
.pipe(plugins.gulpSourcemaps.init())
|
||||
.pipe(plugins.gulpBabel({
|
||||
presets: [
|
||||
require.resolve('babel-preset-es2015')
|
||||
]
|
||||
}))
|
||||
.pipe(plugins.gulpIstanbul({}))
|
||||
.pipe(plugins.gulpSourcemaps.write())
|
||||
.pipe(plugins.gulpInjectModules())
|
||||
.on('finish', function () {
|
||||
let localSmartstream = new plugins.smartstream.Smartstream([
|
||||
plugins.gulp.src([plugins.path.join(paths.cwd, 'test/test.js')]),
|
||||
plugins.gulpBabel({
|
||||
presets: [
|
||||
require.resolve('babel-preset-es2015')
|
||||
]
|
||||
}),
|
||||
plugins.gulpInjectModules(),
|
||||
plugins.gulpMocha(),
|
||||
plugins.gulpIstanbul.writeReports({
|
||||
dir: plugins.path.join(paths.cwd, './coverage'),
|
||||
reporters: ['lcovonly', 'json', 'text', 'text-summary']
|
||||
})
|
||||
]);
|
||||
localSmartstream.run()
|
||||
.then(() => { done.resolve(configArg); }, (err) => {
|
||||
plugins.beautylog.error('Tests failed!');
|
||||
console.log(err);
|
||||
if (configArg.watch) {
|
||||
done.resolve(configArg);
|
||||
}
|
||||
else {
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
let coverage = function (configArg) {
|
||||
let done = q.defer();
|
||||
plugins.smartcov.get.percentage(plugins.path.join(paths.coverageDir, 'lcov.info'), 2)
|
||||
.then(function (percentageArg) {
|
||||
if (percentageArg >= configArg.coverageTreshold) {
|
||||
plugins.beautylog.ok(`${percentageArg.toString()}% `
|
||||
+ `coverage exceeds your treshold of `
|
||||
+ `${configArg.coverageTreshold.toString()}%`);
|
||||
}
|
||||
else {
|
||||
plugins.beautylog.warn(`${percentageArg.toString()}% `
|
||||
+ `coverage fails your treshold of `
|
||||
+ `${configArg.coverageTreshold.toString()}%`);
|
||||
plugins.beautylog.error('exiting due to coverage failure');
|
||||
if (!configArg.watch) {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
done.resolve(configArg);
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
exports.run = function (configArg) {
|
||||
let done = q.defer();
|
||||
let config = configArg;
|
||||
if (config.test === true) {
|
||||
npmts_log_1.npmtsOra.text('now starting tests');
|
||||
plugins.beautylog.log('-------------------------------------------------------\n' +
|
||||
'*************************** TESTS: ***************************\n' +
|
||||
'--------------------------------------------------------------');
|
||||
mocha(config)
|
||||
.then(coverage)
|
||||
.then(() => {
|
||||
done.resolve(config);
|
||||
});
|
||||
}
|
||||
else {
|
||||
npmts_log_1.npmtsOra.end();
|
||||
done.resolve(config);
|
||||
}
|
||||
return done.promise;
|
||||
};
|
9
dist/mod02/mod02.plugins.d.ts
vendored
Normal file
9
dist/mod02/mod02.plugins.d.ts
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
export * from '../npmts.plugins';
|
||||
import * as gulp from 'gulp';
|
||||
import * as gulpBabel from 'gulp-babel';
|
||||
import * as gulpIstanbul from 'gulp-istanbul';
|
||||
import * as gulpFunction from 'gulp-function';
|
||||
declare let gulpInjectModules: any;
|
||||
import * as gulpMocha from 'gulp-mocha';
|
||||
import * as gulpSourcemaps from 'gulp-sourcemaps';
|
||||
export { gulp, gulpBabel, gulpIstanbul, gulpFunction, gulpInjectModules, gulpMocha, gulpSourcemaps };
|
19
dist/mod02/mod02.plugins.js
vendored
Normal file
19
dist/mod02/mod02.plugins.js
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
__export(require("../npmts.plugins"));
|
||||
const gulp = require("gulp");
|
||||
exports.gulp = gulp;
|
||||
const gulpBabel = require("gulp-babel");
|
||||
exports.gulpBabel = gulpBabel;
|
||||
const gulpIstanbul = require("gulp-istanbul");
|
||||
exports.gulpIstanbul = gulpIstanbul;
|
||||
const gulpFunction = require("gulp-function");
|
||||
exports.gulpFunction = gulpFunction;
|
||||
let gulpInjectModules = require('gulp-inject-modules');
|
||||
exports.gulpInjectModules = gulpInjectModules;
|
||||
const gulpMocha = require("gulp-mocha");
|
||||
exports.gulpMocha = gulpMocha;
|
||||
const gulpSourcemaps = require("gulp-sourcemaps");
|
||||
exports.gulpSourcemaps = gulpSourcemaps;
|
Reference in New Issue
Block a user