大口挂在“整理"完成后挂起. [英] Gulp hangs after "Finishing"

查看:65
本文介绍了大口挂在“整理"完成后挂起.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Node的新手,正在任何类型的适当"环境中进行开发.我已经为当前项目安装了gulp以及mocha和其他一些模块.这是我的gulpfile.js:

I'm new to node and developing in any sort of "proper" environment. I've installed gulp for my current project, along with mocha and a few other modules. Here is my gulpfile.js:

var gulp = require('gulp');
var mocha = require('gulp-mocha');
var eslint = require('gulp-eslint');

gulp.task('lint', function () {
    return gulp.src(['js/**/*.js'])
        // eslint() attaches the lint output to the eslint property 
        // of the file object so it can be used by other modules. 
        .pipe(eslint())
        // eslint.format() outputs the lint results to the console. 
        // Alternatively use eslint.formatEach() (see Docs). 
        .pipe(eslint.format())
        // To have the process exit with an error code (1) on 
        // lint error, return the stream and pipe to failOnError last. 
        .pipe(eslint.failOnError());
});

gulp.task('test', function () {
    return gulp.src('tests/test.js', {read: false})
        // gulp-mocha needs filepaths so you can't have any plugins before it 
        .pipe(mocha({reporter: 'list'}));
});

gulp.task('default', ['lint','test'], function () {
    // This will only run if the lint task is successful...
});

当我运行"gulp"时,它似乎完成了所有任务,但挂起了.我必须按ctrl + c才能返回命令提示符.如何使它正确完成?

When I run 'gulp', it appears to complete all its tasks, but hangs. I have to ctrl+c to get back to the command prompt. How do I get it to finish properly?

推荐答案

抱歉,伙计们!事实证明,这是在 gulp-mocha常见问题解答中解决的.引用:

Apologies, folks! Turns out that this is addressed in the gulp-mocha FAQ. To quote:

测试套件未退出

如果您的测试套件未退出,则可能是因为您仍然有回拨,通常是由于打开的数据库引起的 联系.您应该关闭此连接或执行以下操作:

If your test suite is not exiting it might be because you still have a lingering callback, most often caused by an open database connection. You should close this connection or do the following:

gulp.task('default', function () {
    return gulp.src('test.js')
        .pipe(mocha())
        .once('error', function () {
            process.exit(1);
        })
        .once('end', function () {
            process.exit();
        });
});

这篇关于大口挂在“整理"完成后挂起.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆