clean up promise handling for ts compilation

This commit is contained in:
Philipp Kunz 2016-09-15 18:25:09 +02:00
parent 186460d437
commit d4c69071e4
2 changed files with 12 additions and 15 deletions

12
dist/npmts.compile.js vendored
View File

@ -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) {

View File

@ -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
}