2014-09-29 29 views
0

我正在使用节点咕噜为科尔多瓦混合移动开发。为科尔多瓦项目设置并发咕任务

这是我的文件夹结构

myApp 
| 
|__ platforms 
| 
|__ www 
| 
|__ merges 
| 
|__ src 
    | 
    |___ app 
    |  |__ ios 
    |  | |__ js 
    |  | | |__ file1.js 
    |  |__ android 
    |  | |__ js 
    |  | | |__ file2.js 
    |  | | | 
    |__ test 
    |__ Gruntfile.js 
    |__ bower_components 
    |__ package.json 

这是我的咕噜配置(Gruntfile.js)。

module.exports = function(grunt) { 

    var config = { 
    app: 'app', 
    dist: '../www', 
    platform: grunt.option('platform'); 
    }; 

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

    grunt.initConfig({ 

    config: config, 

    jshint: { 
     options: { 
     jshintrc: '.jshintrc' 
     }, 
     all: [ 
     '<%= config.app %>/<%= config.platform %>/js/**/*.js' 
     ] 
    } 

    // Others 
    }); 

    grunt.registerTask('jshint-both-platforms', 'Run jshint for single or both platforms', function() { 

     // if platform is not passed run jshint for both platforms one by one 
     if(config.platform === null) { 

     grunt.config.set('platform', 'ios'); 
     grunt.task.run(['jshint']); 

     grunt.config.set('platform', 'android'); 
     grunt.task.run(['jshint']); 

     grunt.config.set('platform', null); 

     return; 
     } 

     // if the platform is passed run jshint for the passed one 
     grunt.task.run(['jshint']); 
    }); 

    // others 
} 

如果您看到jshint任务配置,我已经为android和ios使用了一个块。

我已经叫jshint-both-platforms自定义任务,对于这两种平台上运行jshint如果用户没有通过在命令行或终端的任何说法。如果您看到自定义任务,我将依次针对两个平台逐一运行jshint任务。

我怎么能运行两个平台同时在jshint任务?咕噜任务

回答