tscoverage/index.js

146 lines
5.3 KiB
JavaScript
Raw Permalink Normal View History

2016-01-14 18:31:53 +00:00
#!/usr/bin/env node
2016-01-16 13:33:09 +00:00
/// <reference path="./index.ts" />
var NpmtsPlugins;
(function (NpmtsPlugins) {
NpmtsPlugins.init = function () {
var plugins = {
beautylog: require("beautylog"),
2016-01-31 21:24:57 +00:00
fs: require("fs-extra"),
2016-01-16 13:33:09 +00:00
gulp: require("gulp"),
2016-01-18 14:15:15 +00:00
g: {
2016-01-18 18:11:42 +00:00
insert: require("gulp-insert"),
sequence: require("gulp-sequence"),
typescript: require("gulp-typescript")
2016-01-18 14:15:15 +00:00
},
mergeStream: require("merge2"),
2016-01-30 04:29:54 +00:00
mocha: require("mocha"),
2016-01-16 13:33:09 +00:00
path: require("path"),
2016-01-30 04:29:54 +00:00
q: require("q"),
2016-01-31 21:24:57 +00:00
smartcli: require("smartcli"),
typings: require("typings")
2016-01-16 13:33:09 +00:00
};
return plugins;
};
})(NpmtsPlugins || (NpmtsPlugins = {}));
/// <reference path="./index.ts" />
/// <reference path="./index.ts" />
var NpmtsPaths;
(function (NpmtsPaths) {
NpmtsPaths.init = function () {
var paths = {};
paths.cwd = plugins.smartcli.get.cwd().path;
2016-01-31 21:24:57 +00:00
paths.tsDir = plugins.path.join(paths.cwd, "ts/");
2016-01-16 13:33:09 +00:00
paths.indexTS = plugins.path.join(paths.cwd, "ts/index.ts");
paths.testTS = plugins.path.join(paths.cwd, "ts/test.ts");
2016-01-30 04:29:54 +00:00
paths.testDir = plugins.path.join(paths.cwd, "test/");
2016-01-16 13:33:09 +00:00
return paths;
};
})(NpmtsPaths || (NpmtsPaths = {}));
2016-01-30 04:29:54 +00:00
/// <reference path="./index.ts" />
var NpmtsOptions;
(function (NpmtsOptions) {
NpmtsOptions.run = function () {
var done = plugins.q.defer();
done.resolve(); //TODO: check for options
return done.promise;
};
})(NpmtsOptions || (NpmtsOptions = {}));
2016-01-31 21:24:57 +00:00
/// <reference path="./index.ts" />
var NpmtsTypings;
(function (NpmtsTypings) {
NpmtsTypings.run = function () {
var done = plugins.q.defer();
plugins.beautylog.log("now installing typings");
plugins.typings.install({ production: false, cwd: paths.tsDir })
.then(function () {
done.resolve();
});
return done.promise;
};
})(NpmtsTypings || (NpmtsTypings = {}));
2016-01-16 13:33:09 +00:00
/// <reference path="./index.ts" />
/// <reference path="./index.ts" />
var NpmtsDefault;
(function (NpmtsDefault) {
2016-01-30 04:29:54 +00:00
NpmtsDefault.run = function () {
var done = plugins.q.defer();
2016-01-18 18:11:42 +00:00
plugins.gulp.task("defaultIndexTS", function () {
plugins.beautylog.log("now compiling" + " ts/index.ts".blue);
2016-01-18 14:15:15 +00:00
var tsResult = plugins.gulp.src(paths.indexTS)
.pipe(plugins.g.typescript({
out: "index.js",
declaration: true
}));
return plugins.mergeStream([
tsResult.dts.pipe(plugins.gulp.dest(paths.cwd)),
tsResult.js
.pipe(plugins.g.insert.prepend('#!/usr/bin/env node\n\n'))
.pipe(plugins.gulp.dest(paths.cwd))
]);
2016-01-16 13:33:09 +00:00
});
2016-01-18 18:11:42 +00:00
plugins.gulp.task("defaultTestTS", function () {
plugins.beautylog.log("now compiling" + " ts/test.ts".blue);
var stream = plugins.gulp.src(paths.testTS)
2016-01-18 14:15:15 +00:00
.pipe(plugins.g.typescript({
2016-01-16 13:33:09 +00:00
out: "test.js"
}))
2016-01-30 04:29:54 +00:00
.pipe(plugins.gulp.dest(paths.testDir));
return stream;
2016-01-16 13:33:09 +00:00
});
2016-01-18 18:11:42 +00:00
plugins.gulp.task("defaultCleanup", function (cb) {
plugins.beautylog.success("TypeScript for this module compiled successfully.");
2016-01-30 04:29:54 +00:00
done.resolve();
2016-01-18 18:11:42 +00:00
cb();
});
plugins.gulp.task("default", function (cb) {
2016-01-31 21:24:57 +00:00
plugins.g.sequence("defaultIndexTS", "defaultTestTS", "defaultCleanup", cb);
2016-01-16 13:33:09 +00:00
});
plugins.gulp.start.apply(plugins.gulp, ['default']);
2016-01-30 04:29:54 +00:00
return done.promise;
2016-01-16 13:33:09 +00:00
};
})(NpmtsDefault || (NpmtsDefault = {}));
2016-01-30 04:29:54 +00:00
/// <reference path="./index.ts" />
var NpmtsTests;
(function (NpmtsTests) {
NpmtsTests.run = function () {
var done = plugins.q.defer();
2016-01-31 21:24:57 +00:00
plugins.fs.ensureDirSync(paths.testDir); //make sure that mocha has a directory to look for tests
2016-01-30 04:29:54 +00:00
plugins.beautylog.info("Now running mocha tests");
2016-01-31 21:24:57 +00:00
var mocha = new plugins.mocha(); // Instantiate a Mocha instance.
2016-01-31 23:24:08 +00:00
mocha.addFile(plugins.path.join(paths.testDir, "test.js"));
2016-01-30 04:29:54 +00:00
mocha.run(function (failures) {
process.on('exit', function () {
process.exit(failures);
});
});
return done.promise;
};
})(NpmtsTests || (NpmtsTests = {}));
/// <reference path="./index.ts" />
var NpmtsPromisechain;
(function (NpmtsPromisechain) {
NpmtsPromisechain.init = function () {
var promisechain;
NpmtsOptions.run()
2016-01-31 21:24:57 +00:00
.then(NpmtsTypings.run)
2016-01-30 04:29:54 +00:00
.then(NpmtsDefault.run)
.then(NpmtsTests.run);
return promisechain;
};
})(NpmtsPromisechain || (NpmtsPromisechain = {}));
2016-01-31 21:24:57 +00:00
/// <reference path="./typings/main.d.ts" />
2016-01-16 13:33:09 +00:00
/// <reference path="./npmts.plugins.ts" />
/// <reference path="./npmts.cli.ts" />
/// <reference path="./npmts.paths.ts" />
2016-01-25 19:52:29 +00:00
/// <reference path="./npmts.options.ts" />
2016-01-31 21:24:57 +00:00
/// <reference path="./npmts.typings.ts" />
2016-01-16 13:33:09 +00:00
/// <reference path="./npmts.custom.ts" />
/// <reference path="./npmts.default.ts" />
2016-01-30 04:29:54 +00:00
/// <reference path="./npmts.tests.ts" />
/// <reference path="./npmts.promisechain.ts" />
2016-01-31 23:24:08 +00:00
console.log("**** starting NPMTS ****");
2016-01-16 13:33:09 +00:00
var plugins = NpmtsPlugins.init();
var paths = NpmtsPaths.init();
2016-01-30 04:29:54 +00:00
var promisechain = NpmtsPromisechain.init();