任务“阻塞”彼此

时间:2015-04-06 11:26:15

标签: node.js gruntjs

我在Grunt中发现了一种奇怪的行为,似乎两个任务相互阻挡(或类似的东西)。任务是:shell(https://github.com/sindresorhus/grunt-shell)和sass(https://github.com/gruntjs/grunt-contrib-sass)。

我的(减少的)Gruntfile;

"use strict";

var path        = require('path');

module.exports = function(grunt) {

    require('time-grunt')(grunt);

    require('load-grunt-tasks')(grunt);

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        shell: {
            options: {
                stdout: true,
                stderr: true
            },
            bower: {
                command: path.resolve(process.cwd() + '/node_modules/.bin/bower --allow-root install')
            }
        },

        /* ... other tasks */

        sass: {
            dist: {
                options: {
                    trace: true
                },

                files: {
                    'dist/additional.css': 'assets/stylesheets/additional.scss'
                }
            }
        }
    });

    grunt.registerTask('default', [
        'shell',
        'sass',
    ]);

}

当我开始grunt时,我的shell任务已经完成但是grunt"停止"在shell任务:

Running "shell:bower" (shell) task

Running "sass:dist" (sass) task

### ctrl + c ###

Execution Time (2015-04-06 10:56:14 UTC)
loading tasks         8.9s  █ 1%
shell:bower          18.6s  ██ 2%
sass:dist        13m 25.2s  ██████████████████████████████████████████████ 97%
Total 13m 52.7s

当我单独开始执行这些任务时(grunt shell分别grunt sass),一切正常。

有什么想法吗?谢谢!

1 个答案:

答案 0 :(得分:2)

切换grunt-shell for fork grunt-shell-spawn并尝试同步运行任务。

shell: {
  options: {
    stdout: true,
    stderr: true,
    async: false
  },
  bower: {
    command: path.resolve(process.cwd() + '/node_modules/.bin/bower --allow-root install')
  }
}
相关问题