hparra / gulp-spawn Goto Github PK
View Code? Open in Web Editor NEWCLI program piping plugin for gulp.
License: MIT License
CLI program piping plugin for gulp.
License: MIT License
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/"));
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?
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?
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
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
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")); }
});
}
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.
BDD style easier to read than assert()
gulp-rename
handles this.
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
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
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.
๐
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
Some modules like gulp-shell and gulp-run prepend the ./node_modules/.bin
to the PATH for the child process, so you have access to all the binaries provided by your module's dependencies.
Would be nice to have this functionally here too.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.