/**
 * Gulp utils for error.
 */
import * as envUtil from "./env-util";

export function handleErrorEvent(): void {
    const transpileContinueOnError = envUtil.get("transpileContinueOnError");
    if (transpileContinueOnError) {
        // @ts-ignore
        // tslint:disable-next-line:no-invalid-this
        (<NodeJS.ReadWriteStream>this).emit("end");
    }
}

export function handleErrorCount(errorCount: number): void {
    const transpileContinueOnError = envUtil.get("transpileContinueOnError");
    if (errorCount > 0 && !transpileContinueOnError) {
        process.exit(1);
    }
}

module.exports = {
    handleErrorCount,
    handleErrorEvent
};

// Generated by UniteJS
