Code Monkey home page Code Monkey logo

gulp-spawn's People

Contributors

beatgammit avatar hparra avatar nfroidure avatar ninbryan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gulp-spawn's Issues

Allow environment variables

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/"));

cwd

Why you haven't added options argument here?

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

For example, i would like to run npm install for submodule of my project, how do i deal with it?
OT: are there any gulp plugins, that can run some task in multiple directories?

looking to run a zip command

After modifying some files, I need to run this command:

zip -r app.nw . -x ".*" "node_modules/*"

I attempted:

    .pipe(spawn({
      cmd: "zip",
      args: [
        '-r',
        'app.nw',
        '.',
        '-x',
        '".*"',
        '"node_modules/*"'
      ]
    }));

but ran into some errors with calling "on" on null. Is gulp-spawn capable of running such a command?

Respect streaming files

file.contents can be a stream sometimes (when buffer: false was given as an argument to .src())

In this case you want to simply do file.contents = file.contents.pipe(spawned_process) instead of buffering in data

Is there any way to spawn several processes in parallel?

I write a gulp script in which I should transform several files with external utility. It looks like:

const { src, dest } = require('gulp');
const spawn = require('gulp-spawn');

exports.build = function build() {
  return src('src/**/*.yml', { buffer: false, nodir: true })
    .pipe(spawn({ cmd: ..., args: ... }))
    .pipe(dest('build/'));
};

Unfortunately, all this is executed very slowly. I would like that it was possible to start several commands at the same time (and the call order to me in this case is unimportant). As node single-thread, I do not think that there can be some parallel-pipe packets (at least, I did not manage to google such). And as the process already spawned asynchronously, it seems logical that this library can be responsible for the parallelism.

If you can add such feature or specify how it can be implemented with existing tools, I would be very grateful

Anything written to stderr causes subsequent gulp commands to halt

Some utilities write debugging or other information to stderr even though they aren't actually errors. An example I have come across recently is using Google Closure compiler called from within gulp.spawn.

I modified index.js to allow for another option called 'failonstderr' that if set to false will simply write to process.stderr and not halt other gulp operations.

if(options.failonstderr !== false)
{
program.stderr.on("end", function () {
if (errBuffer.length) {
stream.emit("error", new gUtil.PluginError(PLUGIN_NAME,
errBuffer.toString("utf-8")));
}
});
}
else
{
program.stderr.on("end", function () {
if (errBuffer.length) { process.stderr.write(errBuffer.toString("utf-8")); }
});
}

Rename npm module

Thanks for renaming from gulp-cli to gulp-spawn. Can you please also rename the npm package? Ideally gulp-cli will be like grunt-cli -- a thin wrapper that discovers the locally installed version and runs it.

Release new version without gulp-util dep

Hi,
I've been using this repo which uses this package and shows warnings about depending on gulp-util dependency of version 4.0.0.

I've seen that the code of this repo was updated 9 months ago (removing deprecated deps.), but the released version was 1 year ago.

Is it ready for a release to npm feed? Can you publish it?

Cheers

Error with Github Actions

I am trying to run gulp-spawn with Github Actions.

Everytime I ran it, it produce following error:

Error in plugin "gulp-spawn"
Message:
    error: unknown option `-p'

Details:
    domainEmitter: [object Object]
    domain: [object Object]
    domainThrown: false

npm ERR! code ELIFECYCLE
npm ERR! errno 1

ENOENT error

Got error while running

Error: spawn sass2less ENOENT
    at _errnoException (util.js:1022:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:192:19)
    at onErrorNT (internal/child_process.js:374:16)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)

I try fix it with:

opts: { cwd: process.env.PATH },

and

opts: { env: { PATH: process.env.PATH } },

No luck.

๐Ÿ

Run arbitrary command

Hi,

If I want to run a command in a task (like run mongod), how would you implement it?

I tried this but it doesn't seem to work, mongod still doesn't run:

gulp.task 'server', () ->
  spawn({ cmd: "mongod" })
  nodemon({ script: 'server.js' })

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.