now compiling Tests seperately

This commit is contained in:
Philipp Kunz 2016-06-07 08:49:22 +02:00
parent 3070584642
commit 48fa9d205a
7 changed files with 70 additions and 55 deletions

View File

@ -1,12 +1,12 @@
"use strict"; "use strict";
var plugins = require("./npmts.plugins"); var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths"); var paths = require("./npmts.paths");
var outputPathIsDir = function (configArg, keyArg) { var outputPathIsDir = function (tsArrayArg, keyArg) {
return plugins.smartpath.check.isDir(plugins.path.join(paths.cwd, configArg.ts[keyArg])); return plugins.smartpath.check.isDir(plugins.path.join(paths.cwd, tsArrayArg[keyArg]));
}; };
exports.checkOutputPath = function (configArg, keyArg) { exports.checkOutputPath = function (tsArrayArg, keyArg) {
if (!outputPathIsDir(configArg, keyArg)) { if (!outputPathIsDir(tsArrayArg, keyArg)) {
plugins.beautylog.warn("Skipping " + keyArg + " because " + configArg.ts[keyArg] + " it is no directory!"); plugins.beautylog.warn("Skipping " + keyArg + " because " + tsArrayArg[keyArg] + " it is no directory!");
return false; return false;
} }
else { else {

44
dist/npmts.compile.js vendored
View File

@ -12,7 +12,7 @@ var definitionHandler = function (configArg) {
var done = plugins.Q.defer(); var done = plugins.Q.defer();
var configTsLenght = Object.keys(configArg.ts).length; var configTsLenght = Object.keys(configArg.ts).length;
if (configTsLenght == 0) { if (configTsLenght == 0) {
plugins.beautylog.warn("No declaration files found... Are you sure you don't want them?"); plugins.beautylog.warn("No TS file and thus no definitions found!");
done.resolve(configArg); //if there are no definition files, resolve... done.resolve(configArg); //if there are no definition files, resolve...
} }
var localCounter = 0; var localCounter = 0;
@ -32,14 +32,10 @@ var definitionHandler = function (configArg) {
} }
return done.promise; return done.promise;
}; };
exports.run = function (configArg) { var compileTs = function (tsFileArrayArg, tsOptionsArg) {
if (tsOptionsArg === void 0) { tsOptionsArg = {}; }
var done = plugins.Q.defer(); var done = plugins.Q.defer();
var config = configArg;
npmts_promisechain_1.npmtsOra.text("now compiling " + "TypeScript".yellow);
var moduleStream = plugins.merge2({ end: false }); var moduleStream = plugins.merge2({ end: false });
/* -------------------------------------------------
* ----------- compile TypeScript --------------------------
* ----------------------------------------------- */
var tsOptionsDefault = { var tsOptionsDefault = {
declaration: true, declaration: true,
target: "ES5", target: "ES5",
@ -49,30 +45,40 @@ exports.run = function (configArg) {
* merges default ts options with those found in npmts.json * merges default ts options with those found in npmts.json
*/ */
var tsOptions = function (keyArg) { var tsOptions = function (keyArg) {
return plugins.lodashObject.assign(tsOptionsDefault, config.tsOptions); return plugins.lodashObject.assign(tsOptionsDefault, tsOptionsArg);
}; };
for (var keyArg in config.ts) { for (var keyArg in tsFileArrayArg) {
if (helpers.checkOutputPath(config, keyArg)) { if (helpers.checkOutputPath(tsFileArrayArg, keyArg)) {
var tsStream = plugins.gulp.src([plugins.path.join(paths.cwd, keyArg), "!**/typings/**"]) var tsStream = plugins.gulp.src([plugins.path.join(paths.cwd, keyArg), "!**/typings/**"])
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated .pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
.pipe(plugins.g.typescript(tsOptions(keyArg))); .pipe(plugins.g.typescript(tsOptions(keyArg)));
var jsStream = tsStream.js var jsStream = tsStream.js
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file .pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
.pipe(plugins.gulp.dest(config.ts[keyArg])); .pipe(plugins.gulp.dest(tsFileArrayArg[keyArg]));
var declarationStream = tsStream.dts var declarationStream = tsStream.dts
.pipe(plugins.gulp.dest(config.ts[keyArg])); .pipe(plugins.gulp.dest(tsFileArrayArg[keyArg]));
moduleStream.add(tsStream, jsStream, declarationStream); moduleStream.add(tsStream, jsStream, declarationStream);
} }
} }
moduleStream.on("queueDrain", function () { moduleStream.on("queueDrain", function () {
moduleStream.on("finish", function () { done.resolve();
plugins.beautylog.ok("compiled TypeScript!"); });
definitionHandler(config) return done.promise;
.then(function () { };
done.resolve(config); exports.run = function (configArg) {
}); var done = plugins.Q.defer();
var config = configArg;
npmts_promisechain_1.npmtsOra.text("now compiling " + "TypeScript".yellow);
compileTs(config.ts, config.tsOptions)
.then(function () {
compileTs(config.tsTest);
})
.then(function () {
plugins.beautylog.ok("compiled TypeScript!");
definitionHandler(config)
.then(function () {
done.resolve(config);
}); });
moduleStream.end();
}); });
/*==================== END TS Compilation =====================*/ /*==================== END TS Compilation =====================*/
return done.promise; return done.promise;

View File

@ -29,9 +29,12 @@ exports.run = function (configArg) {
]; ];
config.ts = (_a = {}, config.ts = (_a = {},
_a["./ts/**/*.ts"] = "./dist/", _a["./ts/**/*.ts"] = "./dist/",
_a["./test/test.ts"] = "./test/",
_a _a
); );
config.testTs = (_b = {},
_b["./test/test.ts"] = "./test/",
_b
);
config.test = ["./index.js"]; config.test = ["./index.js"];
} }
//check if config.tsOptions is available //check if config.tsOptions is available
@ -49,5 +52,5 @@ exports.run = function (configArg) {
plugins.beautylog.ok("build options are ready!"); plugins.beautylog.ok("build options are ready!");
done.resolve(config); done.resolve(config);
return done.promise; return done.promise;
var _a; var _a, _b;
}; };

View File

@ -6,4 +6,4 @@ var testplugin = {
}; };
module.exports = testplugin; module.exports = testplugin;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDZDQUE2QztBQUM3QyxJQUFJLFVBQVUsR0FBRztJQUNiLFlBQVksRUFBRTtRQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQztJQUMxQyxDQUFDO0NBQ0osQ0FBQztBQUNGLE1BQU0sQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9pbmRleC5kLnRzXCIgLz5cclxubGV0IHRlc3RwbHVnaW4gPSB7XHJcbiAgICBsb2dTb21ldGhpbmc6IGZ1bmN0aW9uKCl7XHJcbiAgICAgICAgY29uc29sZS5sb2coXCJvbmx5IGZ1bmN0aW9uIGV4ZWN1dGVkXCIpO1xyXG4gICAgfVxyXG59O1xyXG5tb2R1bGUuZXhwb3J0cyA9IHRlc3RwbHVnaW47Il19 //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDZDQUE2QztBQUM3QyxJQUFJLFVBQVUsR0FBRztJQUNiLFlBQVksRUFBRTtRQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQztJQUMxQyxDQUFDO0NBQ0osQ0FBQztBQUNGLE1BQU0sQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9pbmRleC5kLnRzXCIgLz5cbmxldCB0ZXN0cGx1Z2luID0ge1xuICAgIGxvZ1NvbWV0aGluZzogZnVuY3Rpb24oKXtcbiAgICAgICAgY29uc29sZS5sb2coXCJvbmx5IGZ1bmN0aW9uIGV4ZWN1dGVkXCIpO1xuICAgIH1cbn07XG5tb2R1bGUuZXhwb3J0cyA9IHRlc3RwbHVnaW47Il19

View File

@ -1,13 +1,13 @@
import plugins = require("./npmts.plugins"); import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths"); import paths = require("./npmts.paths");
let outputPathIsDir = function (configArg,keyArg) { let outputPathIsDir = function (tsArrayArg,keyArg) {
return plugins.smartpath.check.isDir(plugins.path.join(paths.cwd, configArg.ts[keyArg])); return plugins.smartpath.check.isDir(plugins.path.join(paths.cwd, tsArrayArg[keyArg]));
}; };
export let checkOutputPath = function(configArg,keyArg){ export let checkOutputPath = function(tsArrayArg,keyArg){
if(!outputPathIsDir(configArg,keyArg)) { if(!outputPathIsDir(tsArrayArg,keyArg)) {
plugins.beautylog.warn("Skipping " + keyArg + " because " + configArg.ts[keyArg] + " it is no directory!") plugins.beautylog.warn("Skipping " + keyArg + " because " + tsArrayArg[keyArg] + " it is no directory!")
return false return false
} else { } else {
return true; return true;

View File

@ -12,7 +12,7 @@ let definitionHandler = function(configArg){
let done = plugins.Q.defer(); let done = plugins.Q.defer();
let configTsLenght = Object.keys(configArg.ts).length; let configTsLenght = Object.keys(configArg.ts).length;
if(configTsLenght == 0) { if(configTsLenght == 0) {
plugins.beautylog.warn("No declaration files found... Are you sure you don't want them?"); plugins.beautylog.warn("No TS file and thus no definitions found!");
done.resolve(configArg); //if there are no definition files, resolve... done.resolve(configArg); //if there are no definition files, resolve...
} }
let localCounter = 0; let localCounter = 0;
@ -33,17 +33,10 @@ let definitionHandler = function(configArg){
return done.promise; return done.promise;
} }
let compileTs = (tsFileArrayArg,tsOptionsArg = {}) => {
export let run = function (configArg) {
let done = plugins.Q.defer(); let done = plugins.Q.defer();
let config = configArg;
npmtsOra.text("now compiling " + "TypeScript".yellow);
let moduleStream = plugins.merge2({ end: false }); let moduleStream = plugins.merge2({ end: false });
/* -------------------------------------------------
* ----------- compile TypeScript --------------------------
* ----------------------------------------------- */
let tsOptionsDefault = { let tsOptionsDefault = {
declaration: true, declaration: true,
target: "ES5", target: "ES5",
@ -54,34 +47,45 @@ export let run = function (configArg) {
* merges default ts options with those found in npmts.json * merges default ts options with those found in npmts.json
*/ */
let tsOptions = function (keyArg:string) { let tsOptions = function (keyArg:string) {
return plugins.lodashObject.assign(tsOptionsDefault, config.tsOptions) return plugins.lodashObject.assign(tsOptionsDefault, tsOptionsArg)
}; };
for (let keyArg in tsFileArrayArg) {
for (let keyArg in config.ts) { if (helpers.checkOutputPath(tsFileArrayArg,keyArg)) {
if (helpers.checkOutputPath(config,keyArg)) {
let tsStream = plugins.gulp.src([plugins.path.join(paths.cwd, keyArg), "!**/typings/**"]) let tsStream = plugins.gulp.src([plugins.path.join(paths.cwd, keyArg), "!**/typings/**"])
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated .pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
.pipe(plugins.g.typescript(tsOptions(keyArg))); .pipe(plugins.g.typescript(tsOptions(keyArg)));
let jsStream = tsStream.js let jsStream = tsStream.js
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file .pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
.pipe(plugins.gulp.dest(config.ts[keyArg])); .pipe(plugins.gulp.dest(tsFileArrayArg[keyArg]));
let declarationStream = tsStream.dts let declarationStream = tsStream.dts
.pipe(plugins.gulp.dest(config.ts[keyArg])); .pipe(plugins.gulp.dest(tsFileArrayArg[keyArg]));
moduleStream.add(tsStream,jsStream,declarationStream); moduleStream.add(tsStream,jsStream,declarationStream);
} }
} }
moduleStream.on("queueDrain",() => {
done.resolve();
})
return done.promise;
}
moduleStream.on("queueDrain", function () {
moduleStream.on("finish", function () { export let run = function (configArg) {
let done = plugins.Q.defer();
let config = configArg;
npmtsOra.text("now compiling " + "TypeScript".yellow);
compileTs(config.ts,config.tsOptions)
.then(() => {
compileTs(config.tsTest);
})
.then(function () {
plugins.beautylog.ok("compiled TypeScript!"); plugins.beautylog.ok("compiled TypeScript!");
definitionHandler(config) definitionHandler(config)
.then(function(){ .then(function(){
done.resolve(config); done.resolve(config);
}); });
}); });
moduleStream.end();
});
/*==================== END TS Compilation =====================*/ /*==================== END TS Compilation =====================*/

View File

@ -33,7 +33,9 @@ export var run = function(configArg){
"./ts/typings.json" "./ts/typings.json"
]; ];
config.ts = { config.ts = {
["./ts/**/*.ts"]: "./dist/", ["./ts/**/*.ts"]: "./dist/"
};
config.testTs = {
["./test/test.ts"]: "./test/" ["./test/test.ts"]: "./test/"
}; };
config.test = ["./index.js"]; config.test = ["./index.js"];