fixed declaration file issue
This commit is contained in:
@ -4,6 +4,36 @@ import paths = require("./npmts.paths");
|
||||
|
||||
import helpers = require("./npmts.compile.helpers");
|
||||
|
||||
/**
|
||||
* handles definition to make them fit for modular use
|
||||
*/
|
||||
let definitionHandler = function(configArg){
|
||||
plugins.beautylog.log("now making declaration files ready");
|
||||
let done = plugins.Q.defer();
|
||||
let configTsLenght = Object.keys(configArg.ts).length;
|
||||
if(configTsLenght == 0) {
|
||||
plugins.beautylog.warn("No declaration files found... Are you sure you don't want them?");
|
||||
done.resolve(configArg); //if there are no definition files, resolve...
|
||||
}
|
||||
let localCounter = 0;
|
||||
for (let key in configArg.ts){
|
||||
let distPath = configArg.ts[key];
|
||||
let stream = plugins.gulp.src(plugins.path.join(distPath,"**/*.d.ts"))
|
||||
.pipe(plugins.g.replace(plugins.smartstring.typescript.regexReferencePath,""))
|
||||
.pipe(plugins.gulp.dest(distPath))
|
||||
.pipe(plugins.g.gFunction(function(){
|
||||
localCounter++
|
||||
if(localCounter == configTsLenght){
|
||||
plugins.beautylog.ok("declaration files ready!!!");
|
||||
done.resolve(configArg)
|
||||
};
|
||||
},"atEnd"));
|
||||
|
||||
}
|
||||
return done.promise;
|
||||
}
|
||||
|
||||
|
||||
export let run = function (configArg) {
|
||||
let done = plugins.Q.defer();
|
||||
let config = configArg;
|
||||
@ -43,18 +73,12 @@ export let run = function (configArg) {
|
||||
}
|
||||
|
||||
moduleStream.on("queueDrain", function () {
|
||||
plugins.beautylog.ok("TypeScript has been compiled!");
|
||||
moduleStream.on("finish", function () {
|
||||
try {
|
||||
if(config.mode = "default") plugins.fs.copySync(
|
||||
plugins.path.join(paths.cwd,"ts/typings"),
|
||||
plugins.path.join(paths.cwd,"dist/typings")
|
||||
);
|
||||
}
|
||||
catch (err){
|
||||
plugins.beautylog.warn("failed to copy external typings for full module declaration support");
|
||||
}
|
||||
done.resolve(config);
|
||||
plugins.beautylog.ok("TypeScript has been compiled!");
|
||||
definitionHandler(config)
|
||||
.then(function(){
|
||||
done.resolve(config);
|
||||
});
|
||||
});
|
||||
moduleStream.end();
|
||||
});
|
||||
|
@ -8,6 +8,7 @@ export let g = {
|
||||
istanbul: require("gulp-istanbul"),
|
||||
jsdoc3: require("gulp-jsdoc3"),
|
||||
mocha: require("gulp-mocha"),
|
||||
replace: require("gulp-replace"),
|
||||
sourcemaps: require("gulp-sourcemaps"),
|
||||
typescript: require("gulp-typescript"),
|
||||
typings: require("gulp-typings")
|
||||
@ -25,4 +26,5 @@ export let smartcov = require("smartcov");
|
||||
export let smartenv = require("smartenv");
|
||||
export let smartfile = require("smartfile");
|
||||
export let smartpath = require("smartpath");
|
||||
export let smartstring = require("smartstring");
|
||||
export let sourceMapSupport = require("source-map-support").install(); // this is required to display errors correctly during testing
|
Reference in New Issue
Block a user