# vinyl-file

> Create a vinyl file from an actual file

Latest version **5.0.0** (published 2022-12-04) · MIT license · 0 weekly downloads

## Install

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

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2022-12-04 |
| First published | 2014-09-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=14.16 |
| Dependencies | 4 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 43 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | vinyl, fs, file, read, virtual, format, gulp, gulpfriendly |

## Links

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

## Dependencies (4)

- [vinyl](https://npm.io/package/vinyl.md) ^3.0.0
- [@types/vinyl](https://npm.io/package/@types/vinyl.md) ^2.0.7
- [strip-bom-buf](https://npm.io/package/strip-bom-buf.md) ^3.0.1
- [strip-bom-stream](https://npm.io/package/strip-bom-stream.md) ^5.0.0

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 5.0.0 (latest) — 2022-12-04
- 4.1.0 — 2022-01-08
- 4.0.0 — 2021-08-15
- 3.0.0 — 2017-01-13
- 2.0.0 — 2015-12-31
- 1.3.0 — 2015-11-14
- 1.2.1 — 2015-06-30
- 1.2.0 — 2015-06-27
- 1.1.1 — 2015-01-12
- 1.1.0 — 2014-09-11
- 1.0.0 — 2014-09-10

## README

# vinyl-file

> Create a [Vinyl file](https://github.com/gulpjs/vinyl) from an actual file

## Install

```sh
npm install vinyl-file
```

## Usage

```js
import {vinylFile} from 'vinyl-file';

const file = await vinylFile('index.js');

console.log(file.path);
//=> '/Users/sindresorhus/dev/vinyl-file/index.js'

console.log(file.cwd);
//=> '/Users/sindresorhus/dev/vinyl-file'
```

## API

### vinylFile(path, options?)

Create a Vinyl file asynchronously and return it.

### vinylFileSync(path, options?)

Create a Vinyl file synchronously and return it.

#### options

Type: `object`

##### base

Type: `string`\
Default: `process.cwd()`

Override the `base` of the Vinyl file.

##### cwd

Type: `string`\
Default: `process.cwd()`

Override the `cwd` (current working directory) of the Vinyl file.

##### buffer

Type: `boolean`\
Default: `true`

Setting this to `false` will return `file.contents` as a stream. This is useful when working with large files.

**Note:** Plugins might not implement support for streams.

##### read

Type: `boolean`\
Default: `true`

Setting this to `false` will return `file.contents` as `null` and not read the file at all.

## Related

- [vinyl-read](https://github.com/SamVerschueren/vinyl-read) - Create vinyl files from glob patterns

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