kotas / gulp-tsc

gulp.js plugin for compiling TypeScript files
69 stars 37 forks source link

Temp Folders are not cleaned up. #10

Closed faysal-ahmad closed 10 years ago

faysal-ahmad commented 10 years ago

In my project I have multiple typescript file groups that need to be compiled separately (a library, and it's unit tests). I have tried adding them both to the same task, and separate tasks. They compile successfully, but the 2nd task leaves behind a temp folder in the project root containing the output file from the 2nd compilation.

kotas commented 10 years ago

@faysal-ahmad Thank you for your report!

I've published v0.2.1 to fix the bug. Please check if it works with you projects.

faysal-ahmad commented 10 years ago

Perfect. Thanks for the quick fix.

Faisal

On Sun, Feb 23, 2014 at 11:04 PM, Kota Saito notifications@github.comwrote:

@faysal-ahmad https://github.com/faysal-ahmad Thank you for your report!

I've published v0.2.1 to fix the bug. Please check if it works with you projects.

Reply to this email directly or view it on GitHubhttps://github.com/kotas/gulp-tsc/issues/10#issuecomment-35838086 .

faysal-ahmad commented 10 years ago

Hi,

I think I emailed a bit prematurely. The temp folders are also left behind if there is a compilation error.

Faisal

On Sun, Feb 23, 2014 at 11:53 PM, Faisal Ahmad faisal.idreesi@gmail.comwrote:

Perfect. Thanks for the quick fix.

Faisal

On Sun, Feb 23, 2014 at 11:04 PM, Kota Saito notifications@github.comwrote:

@faysal-ahmad https://github.com/faysal-ahmad Thank you for your report!

I've published v0.2.1 to fix the bug. Please check if it works with you projects.

Reply to this email directly or view it on GitHubhttps://github.com/kotas/gulp-tsc/issues/10#issuecomment-35838086 .

kotas commented 10 years ago

@faysal-ahmad

I've published v0.2.2 to fix the bug.

Please check again if it surely removes temp dirs since it required a bit sensitive fix due to Node's streams and child processes.

Thank you!

faysal-ahmad commented 10 years ago

Hi,

I removed the emitError flag and ran with the latest version. The temp folders are removed. But I noticed another issue. At the moment, I have 4 compilation sets in a single task. I added a syntax error to the files for the third compilation set. When I looked at the output folder, there were only files for the 1st and the 4th compilation sets. It had not written the output file for the 2nd set, even though it had no errors. When I ran the same again with emitError set to false, it generated the output for the 1st, 2nd and 4th compilation sets as expected.

Faisal

On Mon, Feb 24, 2014 at 11:50 AM, Kota Saito notifications@github.comwrote:

@faysal-ahmad https://github.com/faysal-ahmad

I've published v0.2.2 to fix the bug.

Please check again if it surely removes temp dirs since it required a bit sensitive fix due to Node's streams and child processes.

Thank you!

Reply to this email directly or view it on GitHubhttps://github.com/kotas/gulp-tsc/issues/10#issuecomment-35861551 .

kotas commented 10 years ago

Hmm... Okay, I think it's out of gulp plugin's job to handle exceptions from simultaneous async tasks, since uncaught exception causes all pipes get aborted immediately, which do not allow gulp.dest() to write out the files on the pipe to the disk. gulp-tsc can do nothing about outside of the plugin.

For the moment, I would recomment to use emitError: false as you did, so that you can suppress exceptions from gulp-tsc. However it does not stop running tasks depending on compilation.

If you want to define a task depending on the compilations, like running unit tests only if succeeded to compile all of projects, you will need a bit trick for this.

var gulp = require('gulp');
var typescript = require('gulp-tsc');

gulp.task('default', ['compile'], function () {
    console.log("This task should not be executed if any compilation failed");
});

var compileError = null;
function onerror(err) { compileError = compileError || err; }

gulp.task('compile', ['proj1', 'proj2', 'proj3'], function () {
    if (compileError) throw compileError;
});

gulp.task('proj1', function () {
  return gulp.src('src/proj1/**/*.ts')
    .pipe(typescript()).on('error', onerror)
    .pipe(gulp.dest('build/proj1'));
});
gulp.task('proj2', function () {
  return gulp.src('src/proj2/**/*.ts')
    .pipe(typescript()).on('error', onerror)
    .pipe(gulp.dest('build/proj2'));
});
gulp.task('proj3', function () {
  return gulp.src('src/proj3/**/*.ts')
    .pipe(typescript()).on('error', onerror)
    .pipe(gulp.dest('build/proj3'));
});

Anyway, thank you for spending your time on this! :smiley: