【问题标题】:Stop running nodemon via Gulp停止通过 Gulp 运行 nodemon
【发布时间】:2016-10-01 14:48:21
【问题描述】:

我的想法是,我会使用 nodemon 启动一个具有特定端口的应用程序,然后运行我的测试,最后停止正在运行的应用程序,以便我可以随时再次运行它。

gulp.task('test', function(cb) {
    nodemon({
        script: 'server.js',
        env: { 
            'NODE_ENV': 'test' 
        }
    });

    // Run tests....


    // Stop the application and exit running Gulp -> How to do this?
});

有没有办法停止或强制 ctrl+c 运行 gulp?

谢谢,

凯文

【问题讨论】:

    标签: javascript gulp mocha.js nodemon


    【解决方案1】:

    这些我都知道了

    require('shelljs/global'); // https://github.com/shelljs/shelljs
    
    gulp.task('test', ['nodemon-test', 'mocha-test']);
    
    gulp.task('nodemon-test', function(cb) {
        nodemon({
            script: 'server.js',
            env: { 
                'NODE_ENV': 'test' 
            }
        })
        .on('start', function() {
            cb();
        })
    });
    
    gulp.task('mocha-test', ['nodemon-test'], function() {
        exit(1);
    });
    

    【讨论】:

      猜你喜欢
      • 2017-11-22
      • 1970-01-01
      • 2016-08-07
      • 1970-01-01
      • 2017-10-05
      • 1970-01-01
      • 2015-10-16
      • 1970-01-01
      • 2019-06-22
      相关资源
      最近更新 更多