Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
vinyl-paths
Advanced tools
Get the file paths in a
vinyl
stream
Useful when you need to use the file paths from a Gulp pipeline in an async Node.js package.
Simply pass an async function such as del
and this package will provide each path in the stream as the first argument.
npm install vinyl-paths
// gulpfile.js
import gulp from 'gulp';
import stripDebug from 'gulp-strip-debug';
import del from 'del';
import vinylPaths from 'vinyl-paths';
// Log file paths in the stream
export function log() {
return gulp.src('app/*')
.pipe(stripDebug())
.pipe(vinylPaths(async paths => {
console.log('Paths:', paths);
});
}
// Delete files in the stream
export function delete() {
return gulp.src('app/*')
.pipe(stripDebug())
.pipe(vinylPaths(del));
}
// Or if you need to use the paths after the pipeline
export function delete2() {
return new Promise((resolve, reject) => {
const vp = vinylPaths();
gulp.src('app/*')
.pipe(vp)
.pipe(gulp.dest('dist'))
.on('end', async () => {
try {
await del(vp.paths);
resolve();
} catch (error) {
reject(error);
}
});
});
}
You should only use a vanilla Node.js package like this if you're already using other plugins in the pipeline, otherwise just use the module directly as gulp.src
is costly. Remember that Gulp tasks can return promises as well as streams!
The optional callback will receive a file path for every file and is expected to return a promise. An array of the file paths so far is available as a paths
property on the stream.
file.path
changeFAQs
Get the file paths in a `vinyl` stream
The npm package vinyl-paths receives a total of 14,115 weekly downloads. As such, vinyl-paths popularity was classified as popular.
We found that vinyl-paths 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
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.