2015-04-06 69 views
1

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

My(reduced)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外壳任务完成,但咕噜“停止”的壳任务:

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 shellgrunt sass)seperately开始这些工作一切正常。

任何想法?谢谢!

+0

你可以提供你的package.json上列出的依赖吗? – Rigotti 2015-04-06 13:46:29

+0

查看https://gist.github.com/nehalist/bc0eb3fb5139c495fb46 – nehalist 2015-04-06 14:15:39

回答

2

开关grunt-shell因为它叉grunt-shell-spawn并尝试同步运行任务。

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

只需切换到grunt-shell-spawn而不是grunt-shell,我的问题就解决了:)非常感谢! – nehalist 2015-04-07 10:34:44

+0

不客气。 – Rigotti 2015-04-07 11:39:01