Skip to content

Allow environment variables #12

@thecaddy

Description

@thecaddy

Per http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options should allow passing environment variables.

I'd make a pull request but I'm lazy. Here is the only change line 38 of index.js:

// spawn program
        var program = cp.spawn(options.cmd, options.args, options.opts);

Will allow me to do this:

gulp.src("./src/images/*.{jpg,png,gif}", { buffer: false })
    .pipe(spawn({
        cmd: "convert",
        args: [
            "-",
            "-resize",
            "50%",
            "-"
        ],
       //ENV
       opts: { env: {"NODE_ENV":  "booya"} },
        // optional
        filename: function(base, ext) {
            return base + "-half" + ext;
        }
    }))
    .pipe(gulp.dest("./dist/images/"));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions