# vinyl-paths

> Get the file paths in a `vinyl` stream

Latest version **5.0.0** (published 2022-07-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install vinyl-paths
pnpm add vinyl-paths
yarn add vinyl-paths
bun add vinyl-paths
```

## Health

**Score 28/100 (F)** — status: abandoned.

Positive: has types package; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2022-07-26 |
| First published | 2014-11-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/vinyl-paths) |
| Module format | ESM |
| Node | >=14.16 |
| Dependencies | 1 |
| Unpacked size | 4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 61 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | gulpplugin, vinyl, gulp, paths, path, file, tap, through, stream |

## Links

- npm: https://www.npmjs.com/package/vinyl-paths
- Repository: https://github.com/sindresorhus/vinyl-paths
- Homepage: https://github.com/sindresorhus/vinyl-paths#readme
- Issues: https://github.com/sindresorhus/vinyl-paths/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/vinyl-paths

## Dependencies (1)

- [easy-transform-stream](https://npm.io/package/easy-transform-stream.md) ^1.0.0

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 5.0.0 (latest) — 2022-07-26
- 4.0.0 — 2021-08-15
- 3.0.1 — 2019-11-13
- 3.0.0 — 2019-05-28
- 2.1.0 — 2015-11-14
- 2.0.0 — 2015-08-31
- 1.0.0 — 2014-11-13

## README

# vinyl-paths

> Get the file paths in a [`vinyl`](https://github.com/gulpjs/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`](https://github.com/sindresorhus/del) and this package will provide each path in the stream as the first argument.

## Install

```sh
npm install vinyl-paths
```

## Usage

```js
// 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

- [gulp-revert-path](https://github.com/sindresorhus/gulp-revert-path) - Revert the previous `file.path` change

---
_Source: https://npm.io/package/vinyl-paths · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
