Skip to content
This repository was archived by the owner on Nov 24, 2022. It is now read-only.

Allow objects to be passed as a parameter on the worker-pool method#2

Open
pepjo wants to merge 2 commits intoheikki:masterfrom
pepjo:master
Open

Allow objects to be passed as a parameter on the worker-pool method#2
pepjo wants to merge 2 commits intoheikki:masterfrom
pepjo:master

Conversation

@pepjo
Copy link

@pepjo pepjo commented Aug 26, 2015

I was using your module but I found that I would just love to pass the name of the file gulp needed to minify as a parameter.

I made some modifications in order to do so. Now you can pass a second parameter to the 'makeItFaster' function with some parameters. It's important to notice that I use JSON.stringify, so no functions can be passed.

The parameter is then passed as 'this' to the function.

Code example:

var makeItFaster = require('spawn-task-experiment').workerPool();

gulp.task('whatever', makeItFaster(function() {
    var gulp = require('gulp');
    var sourcemaps = require('gulp-sourcemaps');
    var concat = require('gulp-concat');

    //We get the name
    var name = this.name;

    return gulp.src(['app/' + name + '.js', 'app/**/*.js'])  //We use name
        .pipe(sourcemaps.init())
        .pipe(concat('all.js'))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest('.build/scripts'));
}), 
{
  name: 'hello'
});

PS: This is my first pull request. I hope I did it right.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant