grunt-multi
Advanced tools
Comparing version 0.0.4 to 0.0.5
{ | ||
"name": "grunt-multi", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Run Grunt task with multi-configuration.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -86,12 +86,15 @@ /* | ||
/** | ||
* If multi-vars specified, it will override the configuration. | ||
* example: --multi-vars a=1,2,3:b:jack,bill,rose | ||
* Check if there is any flags specified | ||
* --deb=a.b,hello,hhaah | ||
*/ | ||
if( grunt.option( 'multi-vars' ) ){ | ||
var multiVars = grunt.option( 'multi-vars' ); | ||
var cmdVarsChunk = multiVars.split( ':' ); | ||
cmdVarsChunk.forEach(function( v ){ | ||
var name = v.substring( 0, v.indexOf( '=' ) ); | ||
var values = v.substring( v.indexOf( '=' ) + 1 ); | ||
grunt.option.flags().forEach(function( flag ){ | ||
var EX = /--([^=]+)=(.*)/; | ||
var ret = EX.exec( flag ); | ||
if( ret ){ | ||
var name = ret[ 1 ]; | ||
var values = ret[ 2 ]; | ||
if( name && values ){ | ||
@@ -107,4 +110,4 @@ values = values.split( ',' ); | ||
} | ||
}); | ||
} | ||
} | ||
}); | ||
@@ -155,2 +158,7 @@ grunt.util._.each( vars, function( value, key ){ | ||
// For no vars specified, just use `config` to modify configuration. | ||
if( configDatas.length == 0 && options.config ){ | ||
configDatas.push( {} ); | ||
} | ||
// Render the configs. | ||
@@ -188,3 +196,3 @@ configDatas.forEach(function( data, index ){ | ||
opts: { | ||
env: grunt.util._.merge( process.env, { _grunt_multi_info: JSON.stringify({ config: cfg, tasks: tasks }) } ) | ||
env: JSON.parse( JSON.stringify( grunt.util._.merge( process.env, { _grunt_multi_info: JSON.stringify({ config: cfg, tasks: tasks }) } ) ) ) | ||
}, | ||
@@ -215,3 +223,9 @@ force: ifContinued | ||
if( taskCount == taskLen ){ | ||
done(); | ||
/** Check if this is the last task. | ||
* The _queue will like: [ { placeholder: true }, { placeholder: true } ] | ||
*/ | ||
if( grunt.task._queue.length >= 3 ){ | ||
done(); | ||
} | ||
} | ||
@@ -218,0 +232,0 @@ }); |
@@ -203,3 +203,3 @@ /** | ||
// 先安装npm 依赖 | ||
ChildProcess.exec( 'grunt multi:command --multi-vars page_list=a,b,c:out_target=mod2.js --debug ', function (error, stdout, stderr) { | ||
ChildProcess.exec( 'grunt multi:command --page_list a,b,c --out_target mod2.js --debug ', function (error, stdout, stderr) { | ||
console.log('stdout: ' + stdout); | ||
@@ -206,0 +206,0 @@ console.log('stderr: ' + stderr); |
25805
576