gulp在mocha中导致超时

项目在 https://github.com/cgcgbcbc/gulp-chroot

代码大致如下

javascript// test.js
// ...
it('should work with promise', function(done) {
  gulp.chroot('child', function() {
    gulp.task('promise', function() {
      return gulp.src('test.txt')
                .pipe(through2.obj(function(){
                  console.log('inside promise task');
                  console.log(process.cwd());
                  assert.equal(process.cwd(), path.join(__dirname, 'child'));
                }))
                .pipe(gulp.dest(path.join(__dirname, 'child', '2.txt')));
    });
  });
  gulp.task('sync', ['promise'], function() {
    console.log('inside sync');
    done();
  });
  gulp.start('sync');
});

这个测试在运行时会超时是为什么呢?
运行测试的命令是mocha --harmony --harmon-proxies

阅读 5k
1 个回答

来吧,让你high:

it('should work with promise', function(done) {
    gulp.chroot('child', function() {
        gulp.task('promise', function() {

            return gulp.src('test.txt')
                .pipe((function() {
                    var stream = through2.obj(function(file, encode, next) {
                        console.log('inside promise task');
                        console.log(process.cwd());
                        assert.equal(process.cwd(), path.join(__dirname, 'child'));
                        next();
                    });
                    stream.resume();
                    return stream;
                }()))
                .pipe(gulp.dest(path.join(__dirname, 'child', '2.txt')));
        });
    });
    gulp.task('sync', ['promise'], function() {
        console.log('inside sync');
        done();
    });
    gulp.start('sync');
});
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题