tscoverage/index.js

97 lines
3.7 KiB
JavaScript
Raw 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"),
gulp: require("gulp"),
2016-01-18 14:15:15 +00:00
g: {
2016-01-25 19:24:59 +00:00
if: require("gulp-if"),
2016-01-18 18:11:42 +00:00
insert: require("gulp-insert"),
sequence: require("gulp-sequence"),
tsd: require("gulp-tsd"),
typescript: require("gulp-typescript")
2016-01-18 14:15:15 +00:00
},
mergeStream: require("merge2"),
2016-01-16 13:33:09 +00:00
path: require("path"),
smartcli: require("smartcli")
};
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-18 18:11:42 +00:00
paths.tsd = plugins.path.join(paths.cwd, "ts/tsd.json");
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");
return paths;
};
})(NpmtsPaths || (NpmtsPaths = {}));
/// <reference path="./index.ts" />
/// <reference path="./index.ts" />
var NpmtsDefault;
(function (NpmtsDefault) {
NpmtsDefault.init = function () {
2016-01-18 18:11:42 +00:00
plugins.gulp.task("defaultTsd", function (cb) {
2016-01-25 19:52:29 +00:00
if (!process.env.TRAVIS) {
plugins.g.tsd({
command: 'reinstall',
config: paths.tsd
}, cb);
plugins.beautylog.log("now installing typings from" + " ts/tsd.json".blue);
}
else {
plugins.beautylog.warn("We are on TRAVIS. Typings will not be installed due to GitHub API restrictions.");
plugins.beautylog.log("Make sure the repo tracks " + "typings".blue + " directories");
}
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);
2016-01-16 13:33:09 +00:00
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"
}))
.pipe(plugins.gulp.dest(paths.cwd));
});
2016-01-18 18:11:42 +00:00
plugins.gulp.task("defaultCleanup", function (cb) {
plugins.beautylog.success("TypeScript for this module compiled successfully.");
cb();
});
plugins.gulp.task("default", function (cb) {
plugins.g.sequence("defaultTsd", "defaultIndexTS", "defaultTestTS", "defaultCleanup", cb);
2016-01-16 13:33:09 +00:00
});
plugins.gulp.start.apply(plugins.gulp, ['default']);
};
})(NpmtsDefault || (NpmtsDefault = {}));
2016-01-14 18:25:36 +00:00
/// <reference path="./typings/tsd.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-16 13:33:09 +00:00
/// <reference path="./npmts.custom.ts" />
/// <reference path="./npmts.default.ts" />
var plugins = NpmtsPlugins.init();
var paths = NpmtsPaths.init();
NpmtsDefault.init();