5.0.0 • Published 2 years ago

vinyl-paths v5.0.0

Weekly downloads
28,676
License
MIT
Repository
github
Last release
2 years ago

vinyl-paths

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.

Install

npm install vinyl-paths

Usage

// 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!

API

vinylPaths(callback?)

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.

callback(path)

Related

@instructure/ui-icons-build@rock-kit/ui-icons-buildalex-d.js@spothero/acegui-jvale-dawn-toolsseed-cli-toolsgulp-bsm-helpers@temporg/ui-icons-builddr-comp-packagesimplified-build@everything-registry/sub-chunk-3056templaticagulptraum-sassgulptraum-typescriptangular-markdown-editor-minimalisticangular-gulp-starter-apiangular-slickgrid-fix@appium/gulp-pluginsappium-gulp-plugins@angular-template/ng2-template-build@angular-template/ng1-buildarmor-gulp-pluginsBuildBoxaluminum-capsuleYworkcliYworkshell1000-packagesbf-build-toolsazk-devcakephp-potioncabin-service-clibriksbreeze-gulp@cobalt-engine/slush-cobaltdbreeze-gulpoctaviuscontinuum-gulp@digital-piranesi/iiif-manifest-generatorcgfx-build-toolschewiemozmyllybabel-plugin-import-mucng1-template-gulpmrnodecss-gridishdevelopment-tool-jspmdevelopingo-elixirdevelopment-tool-systemjsphtpitapkg_com_ktaskpoly-theme-cliportal-theme-tasks@viscosoft/remy-clibtpoe-elixir@coinmesh/client-build-tools@deck/presenterenzimify-runkitevadatasecret-elixir@infinitebrahmanuniverse/nolb-vinshark-automationshowcar-gulpfe-gulpds-packreactator-buildds-buildelixir-bustingquick-slurprb-gulp-tasks@evankford/slate-toolsshabeco-build-tools@hvent/laravel-elixirshared-sofa-component-tasksslate-tools-yanggastropod@pivotmade/slate-toolsunion-elixirjclivmt@ribajs/shopify-gulpfm-site-buildfrontend-pipelinefroala-design-blocksspoonx-toolssimpleify-toolssindresorhus.jssmokegen-gulpfont-gisfoolishfoolish-ngfoolish-revslush-theme-patternsslush-globegraphicslush-modulesnp-gulp-taskssmt@nlemoine/gulp-tasksgulp-drinkbar
5.0.0

2 years ago

4.0.0

3 years ago

3.0.1

4 years ago

3.0.0

5 years ago

2.1.0

8 years ago

2.0.0

9 years ago

1.0.0

9 years ago