Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
gulp-collect
Advanced tools
gulp-collect
collects all the (vinyl) files from a stream,
and then calls a given callback once to process all of them.
Here is a dummy example which sorts files by name and then adds properties to the file object to build a doubly linked list.
var gulp = require("gulp");
var collect = require("gulp-collect");
gulp.task("default", function() {
return gulp.src("src/**")
.pipe(collect.list(function(files) {
files.sort(function(a, b) {
if (a.relative < b.relative) return -1;
if (a.relative > b.relative) return +1;
return 0;
});
var prev = files[0];
for (var i = 1; i < files.length; ++i) {
var next = files[i];
prev.nextPath = next.relative;
next.prevPath = prev.relative;
}
return files;
}))
.pipe(gulp.dst("build"));
});
collect.list(handler)
collect.dict(handler)
The plugin exports two different functions.
A stream created using collect.list
will pass the files as a list to
the handler.
A stream created using collect.dict
will instead build a dictionary
using relative path names as keys.
The latter is very similar to how Metalsmith operates,
but the files are still vinyl file objects as gulp uses them.
The handler function has different options regarding its return values.
The handler may return an array or dictionary object.
Even a collect.list
handler may return a dictionary
or a collect.dict
handler may return an array.
The keys of an array are ignored, so if you want to rename a file
make sure that you actually modify its path in the vinyl object.
The handler may return a promise. The value of the promise can be as described above.
The transform stream callback is passed on as a second argument
to the handler.
So the stream may return nothing, but instead call that function
at any time to either signal an error (first argument to the callback)
or a single file (second argument).
Before calling the callback, the handler may call this.push
to push any number of output files.
FAQs
Work on all files of a gulp stream simultaneously
We found that gulp-collect demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.