New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

grunt-multi

Package Overview
Dependencies
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-multi - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

appveyor.yml

4

lib/utils.js

@@ -40,2 +40,4 @@ /**

grunt.log.ok('Spawning new grunt-multi process');
var child = grunt.util.spawn( cfg, function(){

@@ -67,2 +69,2 @@ process.nextTick(function(){

SPAWN_MAX_LIVE = max || SPAWN_MAX_LIVE;
};
};
{
"name": "grunt-multi",
"version": "0.0.6",
"version": "0.0.7",
"description": "Run Grunt task with multi-configuration.",

@@ -22,2 +22,6 @@ "scripts": {

"email": "yinruo.nyj@taobao.com"
},
{
"name": "Renato Rodrigues",
"url" : "https://github.com/rerodrigues"
}

@@ -24,0 +28,0 @@ ],

@@ -1,5 +0,19 @@

# grunt-multi
# grunt-multi [![Build Status: Linux](https://travis-ci.org/rerodrigues/grunt-multi.svg)](https://travis-ci.org/rerodrigues/grunt-multi) [![Build status: Windows](https://ci.appveyor.com/api/projects/status/at7pq24cggun1k6t?svg=true)](https://ci.appveyor.com/project/rerodrigues/grunt-multi)
Run Grunt task with multi-configuration.
> Run Grunt task with multi-configuration.
## Getting Started
If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
```shell
npm install grunt-multi --save-dev
```
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
```js
grunt.loadNpmTasks('grunt-multi');
```
## How to use

@@ -42,3 +56,3 @@

Quite simple, and when you run `grunt build`, you will get all the JS files under `src/a` copyed to `build/a`.
Quite simple, and when you run `grunt build`, you will get all the JS files under `src/a` copied to `build/a`.

@@ -77,3 +91,3 @@ But what if when your project grows larger, maybe you got like `src/b`, `src/c`.. in your project?

},
// A more smart way might be read from an external file.
// A more smart way might be to read from an external file.
external: {

@@ -104,3 +118,3 @@ options: {

},
// For the consideration of flexibility,you can use a function, but note that the return value, must be either an Array or String.
// For the consideration of flexibility,you can use a function, but note that the return value must be either an Array or String.
func: {

@@ -119,3 +133,3 @@ options: {

},
// Also you can use function to direct modify the config, this is useful if you want to get more flexible to modify the configuration.
// Also you can use a function to directly modify the config. This is useful if you want to get more flexibility to modify the configuration.
// params:

@@ -161,6 +175,6 @@ // 1、vars: a single instant of the vars you defined

After configuration you just run `grunt multi:func`( or any defined sub task ) to execute the multi version of copy.
### options
After configuration, you just run `grunt multi:func`( or any defined sub task ) to execute the multi version of copy.
### Options
Available options:

@@ -171,3 +185,3 @@

- `tasks`: the tasks you want to run.
- `continue`: if set to `true`, you indicate that the task will not stop. ( example: watch ).
- `continued`: if set to `true`, you indicate that the task will not stop. ( example: watch ).
- `logBegin`: Function, return log content you want to put in front of a thread.

@@ -177,12 +191,99 @@ - `logEnd`: Function, return log content you want to put after a thread finish.

Options can be specified globally for all `multi` targets and individually within each `multi:target`.
##### Task options (all targets)
```js
//Both targets (list and constant_func) will inherit task options
//and wiil have the vars.page_list = [ 'a', 'b', 'c' ]
multi: {
options : {
vars: {
page_list: [ 'a', 'b', 'c' ]
}
},
list: {
options: {
config: {
targetPage: '<%= page_list %>'
},
tasks: [ 'copy' ]
}
},
constant_func: {
options: {
config: {
targetPage: function( vars, rawConfig ){ return vars.page_list; },
},
tasks: [ 'copy' ]
}
}
}
```
##### Target specific options
```js
//Both targets (list and constant_func) will inherit task options
//but only list target will have vars.page_list = [ 'a', 'b', 'c' ]
//In the constant_func target the global vars.page_list will be
//overwritten by the target specific option vars.page_list = [ 'x', 'y', 'z' ]
multi: {
options : {
vars: {
page_list: [ 'a', 'b', 'c' ]
}
},
list: {
options: {
config: {
targetPage: '<%= page_list %>'
},
tasks: [ 'copy' ]
}
},
constant_func: {
options: {
vars: {
page_list: [ 'x', 'y', 'z' ]
},
config: {
targetPage: function( vars, rawConfig ){ return vars.page_list; },
},
tasks: [ 'copy' ]
}
}
}
```
### Specify `vars` with command
```bash
$ grunt multi:func --page_list a,b,c --outTarget mod2.js
$ grunt multi:func --page_list=a,b,c --outTarget=mod2.js
```
Note that this will override the configuration in `gruntfile.js`.
### Specify `tasks` with command (comma separated)
```bash
$ grunt multi:func --option-tasks=compile
$ grunt multi:func --option-tasks=jshint,build
```
### Specify `continued` with command (defaults to `true`)
```bash
$ grunt multi:func --option-continued
$ grunt multi:func --option-continued=true|false
```
### Specify `maxSpawn` with command
```bash
$ grunt multi:func --option-max-spawn=10
```
Note these options will override the configuration in `Gruntfile.js`.
### How to decide if its a multi-single thread.
In some cases maybe you want to tell if the current thread is a child spawned by `grunt-multi`, just use the `multi-single` option to distinguish:
In some cases, maybe you want to tell if the current thread is a child spawned by `grunt-multi`. Just use the `multi-single` option to distinguish:

@@ -195,2 +296,8 @@ ```

Enjoy!
### Contributing
Your contribution is always welcome. You can contribute with suggestions, comments, reporting issues and of course with code!
If you are planning to submit code please check these simple [development rules](DEVELOPMENT_GUIDE.md) created to maintain the existing coding style and ensure that everything still working as expected.
Enjoy!

@@ -54,3 +54,10 @@ /*

// Get the raw `multi` config, in case the glob-patterns have been replaced by grunt automatically.
var options = grunt.config.getRaw( this.name )[ this.target ].options;
var taskOptions = grunt.config.getRaw( this.name ).options;
var targetOptions = grunt.config.getRaw( this.name )[ this.target ].options;
// Merges global task options with target specific options
var allOptions = [{}].concat([
grunt.util.kindOf(taskOptions) === 'object' ? taskOptions : {},
grunt.util.kindOf(targetOptions) === 'object' ? targetOptions : {}
]);
var options = grunt.util._.extend.apply(null, allOptions);
var maxSpawn = options.maxSpawn;

@@ -83,7 +90,2 @@ var vars = options.vars;

/**
* Set max spawn
*/
Util.spawn.setMax( maxSpawn );
/**
* Separate the option.config

@@ -104,2 +106,10 @@ */

/**
* Accepts continued as a parameter
* --option-continued=true|false
*/
if( !grunt.util._.isUndefined( grunt.option('option-continued') ) ){
ifContinued = String( grunt.option('option-continued') ).toLowerCase() == "true";
}
/**
* Check if there is any flags specified

@@ -111,8 +121,9 @@ * --deb=a.b,hello,hhaah

var EX = /--([^=]+)=(.*)/;
var EX = /--(option-)?([^=]+)=(.*)/;
var ret = EX.exec( flag );
if( ret ){
var name = ret[ 1 ];
var values = ret[ 2 ];
var name = ret[ 2 ];
var values = ret[ 3 ];
var isOption = !grunt.util._.isUndefined( ret[ 1 ] );

@@ -123,2 +134,22 @@ if( name == 'debug' ){

if( isOption && values ){
if( name == 'tasks' ){
values = values.split( ',' );
if( values.length == 1 ){
tasks = values[ 0 ];
}
else {
tasks = values;
}
}
else if( name == 'max-spawn' && !isNaN(values) && values > 0 ){
maxSpawn = parseInt(values, 10);
}
return;
}
if( name && values ){

@@ -218,2 +249,6 @@

}
// preserve --no-write as well
if( grunt.util._.indexOf( process.argv, '--no-write' ) >= 0 ){
args.push( '--no-write' );
}

@@ -226,2 +261,7 @@ var beginLogString = '';

/**
* Set max spawn
*/
Util.spawn.setMax( maxSpawn );
Util.spawn( grunt, {

@@ -228,0 +268,0 @@ grunt: true,

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc