2016-12-19 4 views
0

こんにちは私は、ソリューションをlintsし、lintingプロセスでエラーが発生した後に失敗する次のgulpタスクを持っています。私はそれをテキストで失敗させたいだけでなく、ヒープに落ちるのではなく、この。どんな助けもありがとう。現時点でfailAfterError gulpEslint

gulp.task('lint-solution', function(done){ 
log('Linting solution') 
return gulp.src(['../CRMPortal/**/*.js','../Common/**/*.js','!../Common/scripts/**/*','!../node_modules/**','!../CRMPortal/dist/**','!../CRMPortal/gulpfile.js']) 
    .pipe($.eslint({configFile: ".eslintrc.json"})) 
    .pipe($.eslint.format(
    reporter, function(results){ 
     fs.writeFileSync(path.join(__dirname,'report.html'), results); 
    } 
)) 
    .pipe($.eslint.failAfterError()); <-- I want text I provide to be printed on error here should that be the case , not just the error 
}) 

(明らかに)私が得るすべては次のとおりです。

Message: 
Failed with 1 error 

答えて

1

あなたはこの行を変更することはできません。

Message: 

エラーが発生するたびに、このラインは、ゴクゴク自身で印刷され。エラーが発生した場合にタスクが失敗することはありません。この行は、gulp-eslintによって放出されるエラーオブジェクトに格納され

Failed with 1 error 

あなたはしかし、この行を変更することができます。あなたはストリーム上.on('error')ハンドラを登録することによって、エラーオブジェクトにアクセスして、エラーがgulp-eslintにより放出された場合は、メッセージを変更することができます。

.pipe($.eslint.failAfterError()) 
.on('error', function(err) { 
    if (err.plugin === 'gulp-eslint') { 
    err.message = 'Oops'; 
    } 
}); 

これは以下を出力します

Message: 
    Oops