clean up TypeScript compilation handling
This commit is contained in:
		
							
								
								
									
										34
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								README.md
									
									
									
									
									
								
							@@ -45,9 +45,41 @@ Then use it in package.json's script section to trigger a build:
 | 
				
			|||||||
#### npmts.json
 | 
					#### npmts.json
 | 
				
			||||||
the npmts.json is the main config file. You can use it to customize the behaviour of NPMTS.
 | 
					the npmts.json is the main config file. You can use it to customize the behaviour of NPMTS.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```json
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  "mode":"default",
 | 
				
			||||||
 | 
					  "ts":{
 | 
				
			||||||
 | 
					    "./customdir/*.ts":"./"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "tsconfig":true,
 | 
				
			||||||
 | 
					  "typings":[
 | 
				
			||||||
 | 
					    "./ts/typings.json",
 | 
				
			||||||
 | 
					    "./subts1/typings.json",
 | 
				
			||||||
 | 
					    "./subts2/typings.json",
 | 
				
			||||||
 | 
					    "./customdir/typings.json"
 | 
				
			||||||
 | 
					  ],
 | 
				
			||||||
 | 
					  "codecov":true,
 | 
				
			||||||
 | 
					  "docs": {
 | 
				
			||||||
 | 
					    "publish":true
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "cli":true
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					| key | description |
 | 
				
			||||||
 | 
					| --- | --- |
 | 
				
			||||||
 | 
					| mode | "default" will do some defualt stuff, "custom" only does what you specify |
 | 
				
			||||||
 | 
					| codecov | if true, coverage data will be uploaded to codecov when running on travis |
 | 
				
			||||||
 | 
					| docs | `{"publish":true}` lets you control what happens with your module documentation |
 | 
				
			||||||
 | 
					|  |  |
 | 
				
			||||||
 | 
					|  |  |
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#### Typings
 | 
					#### Typings
 | 
				
			||||||
**npmts** looks for `./ts/typings.json` by default and installs any defined typings to `.ts/typings/`.
 | 
					**npmts** looks for `./ts/typings.json` by default and installs any defined typings to `.ts/typings/`.
 | 
				
			||||||
You can then reference the ./ts/typings/main.d.ts file in any of your TypeScript code.
 | 
					
 | 
				
			||||||
 | 
					> Note: You can reference the typings files in any of your TypeScript code with a  
 | 
				
			||||||
 | 
					`/// <reference path="/some/path/main.d.ts">`  
 | 
				
			||||||
 | 
					or use a tsconfig.json file. 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#### TypeScript
 | 
					#### TypeScript
 | 
				
			||||||
by default npmts looks for `./ts/*.ts` and `./test/test.ts` that will compile to
 | 
					by default npmts looks for `./ts/*.ts` and `./test/test.ts` that will compile to
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										31
									
								
								dist/npmts.compile.helpers.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								dist/npmts.compile.helpers.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
				
			|||||||
 | 
					"use strict";
 | 
				
			||||||
 | 
					var plugins = require("./npmts.plugins");
 | 
				
			||||||
 | 
					var paths = require("./npmts.paths");
 | 
				
			||||||
 | 
					var outputPathIsDir = function (configArg, keyArg) {
 | 
				
			||||||
 | 
					    try {
 | 
				
			||||||
 | 
					        return plugins.fs.statSync(plugins.path.join(paths.cwd, configArg.ts[keyArg])).isDirectory();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    catch (err) {
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					exports.outputNameSpecified = function (configArg, keyArg) {
 | 
				
			||||||
 | 
					    return !outputPathIsDir(configArg, keyArg)
 | 
				
			||||||
 | 
					        && (plugins.path.extname(configArg.ts[keyArg]) == ".js");
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					exports.outputName = function (configArg, keyArg) {
 | 
				
			||||||
 | 
					    if (exports.outputNameSpecified(configArg, keyArg)) {
 | 
				
			||||||
 | 
					        return plugins.path.basename(configArg.ts[keyArg]);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else {
 | 
				
			||||||
 | 
					        return undefined;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					exports.outputDir = function (configArg, keyArg) {
 | 
				
			||||||
 | 
					    if (exports.outputNameSpecified(configArg, keyArg)) {
 | 
				
			||||||
 | 
					        return plugins.path.dirname(plugins.path.join(paths.cwd, configArg.ts[keyArg]));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else {
 | 
				
			||||||
 | 
					        return plugins.path.join(paths.cwd, configArg.ts[keyArg]);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
							
								
								
									
										35
									
								
								dist/npmts.compile.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										35
									
								
								dist/npmts.compile.js
									
									
									
									
										vendored
									
									
								
							@@ -2,6 +2,7 @@
 | 
				
			|||||||
/// <reference path="./typings/main.d.ts" />
 | 
					/// <reference path="./typings/main.d.ts" />
 | 
				
			||||||
var plugins = require("./npmts.plugins");
 | 
					var plugins = require("./npmts.plugins");
 | 
				
			||||||
var paths = require("./npmts.paths");
 | 
					var paths = require("./npmts.paths");
 | 
				
			||||||
 | 
					var helpers = require("./npmts.compile.helpers");
 | 
				
			||||||
exports.run = function (configArg) {
 | 
					exports.run = function (configArg) {
 | 
				
			||||||
    var done = plugins.Q.defer();
 | 
					    var done = plugins.Q.defer();
 | 
				
			||||||
    var config = configArg;
 | 
					    var config = configArg;
 | 
				
			||||||
@@ -11,43 +12,15 @@ exports.run = function (configArg) {
 | 
				
			|||||||
     * ----------- compile TypeScript --------------------------
 | 
					     * ----------- compile TypeScript --------------------------
 | 
				
			||||||
     * ----------------------------------------------- */
 | 
					     * ----------------------------------------------- */
 | 
				
			||||||
    for (var key in config.ts) {
 | 
					    for (var key in config.ts) {
 | 
				
			||||||
        var outputPathIsDir;
 | 
					 | 
				
			||||||
        try {
 | 
					 | 
				
			||||||
            if (plugins.fs.statSync(plugins.path.join(paths.cwd, config.ts[key])).isDirectory()) {
 | 
					 | 
				
			||||||
                outputPathIsDir = true;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        catch (err) {
 | 
					 | 
				
			||||||
            outputPathIsDir = false;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        //do some evaluation of the environment
 | 
					 | 
				
			||||||
        var outputNameSpecified = (!outputPathIsDir
 | 
					 | 
				
			||||||
            && (plugins.path.extname(config.ts[key]) == ".js"));
 | 
					 | 
				
			||||||
        var outputName = (function () {
 | 
					 | 
				
			||||||
            if (outputNameSpecified) {
 | 
					 | 
				
			||||||
                return plugins.path.basename(config.ts[key]);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            else {
 | 
					 | 
				
			||||||
                return undefined;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        })();
 | 
					 | 
				
			||||||
        var outputDir = (function () {
 | 
					 | 
				
			||||||
            if (outputNameSpecified) {
 | 
					 | 
				
			||||||
                return plugins.path.dirname(plugins.path.join(paths.cwd, config.ts[key]));
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            else {
 | 
					 | 
				
			||||||
                return plugins.path.join(paths.cwd, config.ts[key]);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        })();
 | 
					 | 
				
			||||||
        var stream = plugins.gulp.src([plugins.path.join(paths.cwd, key), "!**/typings/**"])
 | 
					        var stream = plugins.gulp.src([plugins.path.join(paths.cwd, key), "!**/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({
 | 
					            .pipe(plugins.g.typescript({
 | 
				
			||||||
            out: outputName,
 | 
					            out: helpers.outputName(config, key),
 | 
				
			||||||
            target: "ES5",
 | 
					            target: "ES5",
 | 
				
			||||||
            module: "commonjs"
 | 
					            module: "commonjs"
 | 
				
			||||||
        }))
 | 
					        }))
 | 
				
			||||||
            .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(outputDir));
 | 
					            .pipe(plugins.gulp.dest(helpers.outputDir(config, key)));
 | 
				
			||||||
        moduleStream.add(stream);
 | 
					        moduleStream.add(stream);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    moduleStream.on("queueDrain", function () {
 | 
					    moduleStream.on("queueDrain", function () {
 | 
				
			||||||
@@ -57,6 +30,6 @@ exports.run = function (configArg) {
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
        moduleStream.end();
 | 
					        moduleStream.end();
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    /*==================== END TYPESCRIPT =====================*/
 | 
					    /*==================== END TS Compilation =====================*/
 | 
				
			||||||
    return done.promise;
 | 
					    return done.promise;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										10
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								package.json
									
									
									
									
									
								
							@@ -26,7 +26,7 @@
 | 
				
			|||||||
  "homepage": "https://github.com/pushrocks/npmts#readme",
 | 
					  "homepage": "https://github.com/pushrocks/npmts#readme",
 | 
				
			||||||
  "dependencies": {
 | 
					  "dependencies": {
 | 
				
			||||||
    "beautylog": "4.1.2",
 | 
					    "beautylog": "4.1.2",
 | 
				
			||||||
    "fs-extra": "^0.26.7",
 | 
					    "fs-extra": "^0.30.0",
 | 
				
			||||||
    "gulp": "3.9.1",
 | 
					    "gulp": "3.9.1",
 | 
				
			||||||
    "gulp-codecov": "^2.0.1",
 | 
					    "gulp-codecov": "^2.0.1",
 | 
				
			||||||
    "gulp-concat": "^2.6.0",
 | 
					    "gulp-concat": "^2.6.0",
 | 
				
			||||||
@@ -35,18 +35,18 @@
 | 
				
			|||||||
    "gulp-istanbul": "^0.10.4",
 | 
					    "gulp-istanbul": "^0.10.4",
 | 
				
			||||||
    "gulp-jsdoc3": "^0.2.1",
 | 
					    "gulp-jsdoc3": "^0.2.1",
 | 
				
			||||||
    "gulp-mocha": "^2.2.0",
 | 
					    "gulp-mocha": "^2.2.0",
 | 
				
			||||||
    "gulp-sourcemaps": "^1.6.0",
 | 
					    "gulp-sourcemaps": "^2.0.0-alpha",
 | 
				
			||||||
    "gulp-typescript": "2.12.2",
 | 
					    "gulp-typescript": "2.13.0",
 | 
				
			||||||
    "gulp-typings": "1.3.4",
 | 
					    "gulp-typings": "1.3.4",
 | 
				
			||||||
    "merge2": "1.0.2",
 | 
					    "merge2": "1.0.2",
 | 
				
			||||||
    "projectinfo": "1.0.1",
 | 
					    "projectinfo": "1.0.1",
 | 
				
			||||||
    "q": "^1.4.1",
 | 
					    "q": "^1.4.1",
 | 
				
			||||||
    "shelljs": "^0.6.0",
 | 
					    "shelljs": "^0.7.0",
 | 
				
			||||||
    "smartci": "0.0.1",
 | 
					    "smartci": "0.0.1",
 | 
				
			||||||
    "smartcli": "0.0.11",
 | 
					    "smartcli": "0.0.11",
 | 
				
			||||||
    "smartcov": "0.0.6",
 | 
					    "smartcov": "0.0.6",
 | 
				
			||||||
    "smartenv": "1.2.2",
 | 
					    "smartenv": "1.2.2",
 | 
				
			||||||
    "smartfile": "3.0.3",
 | 
					    "smartfile": "3.0.5",
 | 
				
			||||||
    "smartpath": "3.1.4",
 | 
					    "smartpath": "3.1.4",
 | 
				
			||||||
    "source-map-support": "^0.4.0"
 | 
					    "source-map-support": "^0.4.0"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								test/assets/dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								test/assets/dist/index.js
									
									
									
									
										vendored
									
									
								
							@@ -6,4 +6,4 @@ var testplugin = {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
module.exports = testplugin;
 | 
					module.exports = testplugin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0QztBQUM1QyxJQUFJLFVBQVUsR0FBRztJQUNiLFlBQVksRUFBRTtRQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQztJQUMxQyxDQUFDO0NBQ0osQ0FBQztBQUNGLE1BQU0sQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxubGV0IHRlc3RwbHVnaW4gPSB7XG4gICAgbG9nU29tZXRoaW5nOiBmdW5jdGlvbigpe1xuICAgICAgICBjb25zb2xlLmxvZyhcIm9ubHkgZnVuY3Rpb24gZXhlY3V0ZWRcIik7XG4gICAgfVxufTtcbm1vZHVsZS5leHBvcnRzID0gdGVzdHBsdWdpbjsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
 | 
					//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0QztBQUM1QyxJQUFJLFVBQVUsR0FBRztJQUNiLFlBQVksRUFBRTtRQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQztJQUMxQyxDQUFDO0NBQ0osQ0FBQztBQUNGLE1BQU0sQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxubGV0IHRlc3RwbHVnaW4gPSB7XG4gICAgbG9nU29tZXRoaW5nOiBmdW5jdGlvbigpe1xuICAgICAgICBjb25zb2xlLmxvZyhcIm9ubHkgZnVuY3Rpb24gZXhlY3V0ZWRcIik7XG4gICAgfVxufTtcbm1vZHVsZS5leHBvcnRzID0gdGVzdHBsdWdpbjsiXX0=
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,6 +3,7 @@
 | 
				
			|||||||
  "ts":{
 | 
					  "ts":{
 | 
				
			||||||
    "./customdir/*.ts":"./"
 | 
					    "./customdir/*.ts":"./"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					  "tsconfig":true,
 | 
				
			||||||
  "typings":[
 | 
					  "typings":[
 | 
				
			||||||
    "./ts/typings.json",
 | 
					    "./ts/typings.json",
 | 
				
			||||||
    "./subts1/typings.json",
 | 
					    "./subts1/typings.json",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,4 +8,4 @@ describe("testplugins", function () {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0RBQWdEO0FBQ2hELElBQUksVUFBVSxHQUFHLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxDQUFDO0FBQzdDLFFBQVEsQ0FBQyxhQUFhLEVBQUM7SUFDbkIsUUFBUSxDQUFDLGVBQWUsRUFBQztRQUNyQixFQUFFLENBQUMsc0JBQXNCLEVBQUM7WUFDdEIsVUFBVSxDQUFDLFlBQVksRUFBRSxDQUFBO1FBQzdCLENBQUMsQ0FBQyxDQUFDO0lBQ1AsQ0FBQyxDQUFDLENBQUM7QUFDUCxDQUFDLENBQUMsQ0FBQyIsImZpbGUiOiJ0ZXN0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4uL3RzL3R5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbnZhciB0ZXN0cGx1Z2luID0gcmVxdWlyZShcIi4uL2Rpc3QvaW5kZXguanNcIik7XG5kZXNjcmliZShcInRlc3RwbHVnaW5zXCIsZnVuY3Rpb24oKXtcbiAgICBkZXNjcmliZShcIi5sb2dTb21ldGhpbmdcIixmdW5jdGlvbigpe1xuICAgICAgICBpdChcInNob3VsZCBsb2cgc29tZXRoaW5nXCIsZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIHRlc3RwbHVnaW4ubG9nU29tZXRoaW5nKClcbiAgICAgICAgfSk7XG4gICAgfSk7XG59KTsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
 | 
					//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0RBQWdEO0FBQ2hELElBQUksVUFBVSxHQUFHLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxDQUFDO0FBQzdDLFFBQVEsQ0FBQyxhQUFhLEVBQUM7SUFDbkIsUUFBUSxDQUFDLGVBQWUsRUFBQztRQUNyQixFQUFFLENBQUMsc0JBQXNCLEVBQUM7WUFDdEIsVUFBVSxDQUFDLFlBQVksRUFBRSxDQUFBO1FBQzdCLENBQUMsQ0FBQyxDQUFDO0lBQ1AsQ0FBQyxDQUFDLENBQUM7QUFDUCxDQUFDLENBQUMsQ0FBQyIsImZpbGUiOiJ0ZXN0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4uL3RzL3R5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbnZhciB0ZXN0cGx1Z2luID0gcmVxdWlyZShcIi4uL2Rpc3QvaW5kZXguanNcIik7XG5kZXNjcmliZShcInRlc3RwbHVnaW5zXCIsZnVuY3Rpb24oKXtcbiAgICBkZXNjcmliZShcIi5sb2dTb21ldGhpbmdcIixmdW5jdGlvbigpe1xuICAgICAgICBpdChcInNob3VsZCBsb2cgc29tZXRoaW5nXCIsZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIHRlc3RwbHVnaW4ubG9nU29tZXRoaW5nKClcbiAgICAgICAgfSk7XG4gICAgfSk7XG59KTsiXX0=
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										34
									
								
								ts/npmts.compile.helpers.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								ts/npmts.compile.helpers.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
				
			|||||||
 | 
					import plugins = require("./npmts.plugins");
 | 
				
			||||||
 | 
					import paths = require("./npmts.paths");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					let outputPathIsDir = function (configArg,keyArg) {
 | 
				
			||||||
 | 
					    try {
 | 
				
			||||||
 | 
					        return plugins.fs.statSync(plugins.path.join(paths.cwd, configArg.ts[keyArg])).isDirectory();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    catch (err) {
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export let outputNameSpecified = function (configArg, keyArg) {
 | 
				
			||||||
 | 
					    return !outputPathIsDir(configArg,keyArg)
 | 
				
			||||||
 | 
					        && (plugins.path.extname(configArg.ts[keyArg]) == ".js");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export let outputName = function (configArg, keyArg) {
 | 
				
			||||||
 | 
					    if (outputNameSpecified(configArg,keyArg)) {
 | 
				
			||||||
 | 
					        return plugins.path.basename(configArg.ts[keyArg])
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        return undefined
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export let outputDir = function (configArg, keyArg) {
 | 
				
			||||||
 | 
					    if (outputNameSpecified(configArg,keyArg)) {
 | 
				
			||||||
 | 
					        return plugins.path.dirname(
 | 
				
			||||||
 | 
					            plugins.path.join(paths.cwd, configArg.ts[keyArg])
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        return plugins.path.join(paths.cwd, configArg.ts[keyArg])
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@@ -1,59 +1,31 @@
 | 
				
			|||||||
/// <reference path="./typings/main.d.ts" />
 | 
					/// <reference path="./typings/main.d.ts" />
 | 
				
			||||||
import plugins = require("./npmts.plugins");
 | 
					import plugins = require("./npmts.plugins");
 | 
				
			||||||
import paths = require("./npmts.paths");
 | 
					import paths = require("./npmts.paths");
 | 
				
			||||||
export var run = function(configArg){
 | 
					
 | 
				
			||||||
    var done = plugins.Q.defer();
 | 
					import helpers = require("./npmts.compile.helpers");
 | 
				
			||||||
    var config = configArg;
 | 
					
 | 
				
			||||||
 | 
					export let run = function(configArg){
 | 
				
			||||||
 | 
					    let done = plugins.Q.defer();
 | 
				
			||||||
 | 
					    let config = configArg;
 | 
				
			||||||
    plugins.beautylog.log("now compiling " + "TypeScript".yellow);
 | 
					    plugins.beautylog.log("now compiling " + "TypeScript".yellow);
 | 
				
			||||||
    var moduleStream = plugins.merge2({end: false});
 | 
					    let moduleStream = plugins.merge2({end: false});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* -------------------------------------------------
 | 
					    /* -------------------------------------------------
 | 
				
			||||||
     * ----------- compile TypeScript --------------------------
 | 
					     * ----------- compile TypeScript --------------------------
 | 
				
			||||||
     * ----------------------------------------------- */
 | 
					     * ----------------------------------------------- */
 | 
				
			||||||
    for (var key in config.ts) {
 | 
					    for (let key in config.ts) {
 | 
				
			||||||
        var outputPathIsDir:boolean;
 | 
					        let stream = plugins.gulp.src([plugins.path.join(paths.cwd,key),"!**/typings/**"])
 | 
				
			||||||
        try {
 | 
					 | 
				
			||||||
            if(plugins.fs.statSync(plugins.path.join(paths.cwd,config.ts[key])).isDirectory()){
 | 
					 | 
				
			||||||
                outputPathIsDir = true;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        catch(err) {
 | 
					 | 
				
			||||||
            outputPathIsDir = false;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        //do some evaluation of the environment
 | 
					 | 
				
			||||||
        var outputNameSpecified:boolean = (
 | 
					 | 
				
			||||||
            !outputPathIsDir
 | 
					 | 
				
			||||||
            && (plugins.path.extname(config.ts[key]) == ".js")
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
        var outputName = (function(){
 | 
					 | 
				
			||||||
            if(outputNameSpecified){
 | 
					 | 
				
			||||||
                return plugins.path.basename(config.ts[key])
 | 
					 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                return undefined
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        })();
 | 
					 | 
				
			||||||
        var outputDir = (function(){
 | 
					 | 
				
			||||||
            if(outputNameSpecified){
 | 
					 | 
				
			||||||
                return plugins.path.dirname(
 | 
					 | 
				
			||||||
                    plugins.path.join(paths.cwd,config.ts[key])
 | 
					 | 
				
			||||||
                )
 | 
					 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                return plugins.path.join(paths.cwd,config.ts[key])
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        })();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        var stream = plugins.gulp.src([plugins.path.join(paths.cwd,key),"!**/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({
 | 
					            .pipe(plugins.g.typescript({
 | 
				
			||||||
                out: outputName,
 | 
					                out: helpers.outputName(config,key),
 | 
				
			||||||
                target: "ES5",
 | 
					                target: "ES5",
 | 
				
			||||||
                module: "commonjs"
 | 
					                module: "commonjs"
 | 
				
			||||||
            }))
 | 
					            }))
 | 
				
			||||||
            .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.g.header('#!/usr/bin/env node\n\n'))
 | 
					            .pipe(plugins.gulp.dest(helpers.outputDir(config,key)));
 | 
				
			||||||
            .pipe(plugins.gulp.dest(outputDir));
 | 
					 | 
				
			||||||
        moduleStream.add(stream);
 | 
					        moduleStream.add(stream);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    moduleStream.on("queueDrain",function(){
 | 
					    moduleStream.on("queueDrain",function(){
 | 
				
			||||||
        plugins.beautylog.ok("TypeScript has been compiled!");
 | 
					        plugins.beautylog.ok("TypeScript has been compiled!");
 | 
				
			||||||
        moduleStream.on("finish",function(){
 | 
					        moduleStream.on("finish",function(){
 | 
				
			||||||
@@ -61,7 +33,7 @@ export var run = function(configArg){
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
        moduleStream.end();
 | 
					        moduleStream.end();
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    /*==================== END TYPESCRIPT =====================*/
 | 
					    /*==================== END TS Compilation =====================*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user