clean up promise handling for ts compilation
This commit is contained in:
		
							
								
								
									
										12
									
								
								dist/npmts.compile.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								dist/npmts.compile.js
									
									
									
									
										vendored
									
									
								
							@@ -28,22 +28,20 @@ var compileTs = function (tsFileArrayArg, tsOptionsArg) {
 | 
			
		||||
    var _loop_1 = function (keyArg) {
 | 
			
		||||
        plugins.beautylog.info("TypeScript assignment: transpile from " + keyArg.blue + " to " + tsFileArrayArg[keyArg].blue);
 | 
			
		||||
        if (helpers.checkOutputPath(tsFileArrayArg, keyArg)) {
 | 
			
		||||
            var filesReadPromise = plugins.smartfile.fs.listFileTree(process.cwd(), keyArg)
 | 
			
		||||
            plugins.smartfile.fs.listFileTree(process.cwd(), keyArg)
 | 
			
		||||
                .then(function (filesToConvertArg) {
 | 
			
		||||
                var filesToConvertAbsolute = plugins.smartpath.transform.toAbsolute(filesToConvertArg, process.cwd());
 | 
			
		||||
                var destDir = plugins.smartpath.transform.toAbsolute(tsFileArrayArg[keyArg], process.cwd());
 | 
			
		||||
                var filesCompiledPromise = plugins.tsn.compile(filesToConvertAbsolute, destDir, compilerOptions(keyArg));
 | 
			
		||||
                promiseArray.push(filesCompiledPromise);
 | 
			
		||||
                return plugins.tsn.compile(filesToConvertAbsolute, destDir, compilerOptions(keyArg));
 | 
			
		||||
            })
 | 
			
		||||
                .then(function () {
 | 
			
		||||
                done.resolve();
 | 
			
		||||
            });
 | 
			
		||||
            promiseArray.push(filesReadPromise);
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
    for (var keyArg in tsFileArrayArg) {
 | 
			
		||||
        _loop_1(keyArg);
 | 
			
		||||
    }
 | 
			
		||||
    ;
 | 
			
		||||
    plugins.Q.all(promiseArray)
 | 
			
		||||
        .then(done.resolve);
 | 
			
		||||
    return done.promise;
 | 
			
		||||
};
 | 
			
		||||
exports.run = function (configArg) {
 | 
			
		||||
 
 | 
			
		||||
@@ -30,22 +30,21 @@ let compileTs = (tsFileArrayArg: string[],tsOptionsArg = {}) => {
 | 
			
		||||
    for (let keyArg in tsFileArrayArg) {
 | 
			
		||||
        plugins.beautylog.info(`TypeScript assignment: transpile from ${keyArg.blue} to ${tsFileArrayArg[keyArg].blue}`)
 | 
			
		||||
        if (helpers.checkOutputPath(tsFileArrayArg,keyArg)) {
 | 
			
		||||
            let filesReadPromise = plugins.smartfile.fs.listFileTree(process.cwd(),keyArg)
 | 
			
		||||
                .then((filesToConvertArg) => {
 | 
			
		||||
            plugins.smartfile.fs.listFileTree(process.cwd(),keyArg)
 | 
			
		||||
                .then((filesToConvertArg: string[]) => {
 | 
			
		||||
                    let filesToConvertAbsolute = plugins.smartpath.transform.toAbsolute(filesToConvertArg,process.cwd())
 | 
			
		||||
                    let destDir = plugins.smartpath.transform.toAbsolute(tsFileArrayArg[keyArg],process.cwd())
 | 
			
		||||
                    let filesCompiledPromise = plugins.tsn.compile(
 | 
			
		||||
                    return plugins.tsn.compile(
 | 
			
		||||
                        filesToConvertAbsolute,
 | 
			
		||||
                        destDir,
 | 
			
		||||
                        compilerOptions(keyArg)
 | 
			
		||||
                    )
 | 
			
		||||
                    promiseArray.push(filesCompiledPromise)
 | 
			
		||||
                })
 | 
			
		||||
            promiseArray.push(filesReadPromise)
 | 
			
		||||
                .then(() => {
 | 
			
		||||
                    done.resolve()
 | 
			
		||||
                })
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
    plugins.Q.all(promiseArray)
 | 
			
		||||
        .then(done.resolve)
 | 
			
		||||
    }
 | 
			
		||||
    return done.promise
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user