# @wrote/ensure-path

> Create all directories on the way to the path.

Latest version **1.1.0** (published 2019-07-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @wrote/ensure-path
pnpm add @wrote/ensure-path
yarn add @wrote/ensure-path
bun add @wrote/ensure-path
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2019-07-03 |
| First published | 2018-07-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Anton |
| Maintainers | zvr |
| Keywords | @wrote, path, ensure, traverse, tree, fs, filesystem, directory, dir, folder, file, create, mkdirp, mkdir |

## Links

- npm: https://www.npmjs.com/package/@wrote/ensure-path
- Repository: https://github.com/wrote/ensure-path
- Homepage: https://github.com/wrote/ensure-path#readme
- Issues: https://github.com/wrote/ensure-path/issues
- npm.io page: https://npm.io/package/@wrote/ensure-path

## Dependencies (1)

- [makepromise](https://npm.io/package/makepromise.md) ^3.1.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

- 1.1.0 (latest) — 2019-07-03
- 1.0.8 — 2019-04-18
- 1.0.7 — 2019-04-18
- 1.0.6 — 2019-04-02
- 1.0.5 — 2019-01-14
- 1.0.4 — 2019-01-14
- 1.0.3 — 2018-09-15
- 1.0.2 — 2018-07-04
- 1.0.1 — 2018-07-03
- 1.0.0 — 2018-07-03

## README

# @wrote/ensure-path

[![npm version](https://badge.fury.io/js/%40wrote%2Fensure-path.svg)](https://npmjs.org/package/@wrote/ensure-path)

`@wrote/ensure-path` Creates All Directories On The Way To The Path.

```sh
yarn add @wrote/ensure-path
```

<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/0.svg?sanitize=true"></a></p>

## Table Of Contents

- [Table Of Contents](#table-of-contents)
- [API](#api)
  * [`async ensurePath(path: string): string`](#async-ensurepathpath-string-string)
  * [`ensurePathSync(path: string): string`](#ensurepathsyncpath-string-string)
- [Copyright](#copyright)

<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/1.svg?sanitize=true"></a></p>

## API

The package is available by importing its default and named function:

```js
import ensurePath, { ensurePathSync } from '@wrote/ensure-path'
```

<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/2.svg?sanitize=true"></a></p>

### `async ensurePath(`<br/>&nbsp;&nbsp;`path: string,`<br/>`): string`

Makes sure that the path can be written to by recursively creating all necessary directories. Returns the same path as passed to the function.

```js
import { resolve } from 'path'
import ensurePath from '@wrote/ensure-path'

(async () => {
  const path = 'example/path/to/temp/file.data'
  await ensurePath(path)
  // path/to/temp is created in the cwd

  const absolutePath = resolve('example/path/to/temp/file.data')
  await ensurePath(absolutePath)
  // $(pwd)/path/to/temp/file.data is created
})()
```

<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/3.svg?sanitize=true"></a></p>

### `ensurePathSync(`<br/>&nbsp;&nbsp;`path: string,`<br/>`): string`

Same as `ensurePath`, but performed synchronously.

```js
import { resolve } from 'path'
import { ensurePathSync } from '@wrote/ensure-path'

const path = 'example/path/to/temp/file.data'
ensurePathSync(path)
// path/to/temp is created in the cwd

const absolutePath = resolve('example/path/to/temp/file.data')
ensurePathSync(absolutePath)
// $(pwd)/path/to/temp/file.data is created
```

<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/4.svg?sanitize=true"></a></p>

## Copyright

<table>
  <tr>
    <th>
      <a href="https://artd.eco">
        <img src="https://raw.githubusercontent.com/wrote/wrote/master/images/artdeco.png" alt="Art Deco">
      </a>
    </th>
    <th>© <a href="https://artd.eco">Art Deco</a> for <a href="https://wrote.cc">Wrote</a> 2019</th>
    <th>
      <a href="https://wrote.cc">
        <img src="https://avatars3.githubusercontent.com/u/40831417?s=100" width="100" alt="Wrote">
      </a>
    </th>
    <th>
      <a href="https://www.technation.sucks" title="Tech Nation Visa">
        <img src="https://raw.githubusercontent.com/artdecoweb/www.technation.sucks/master/anim.gif"
          alt="Tech Nation Visa">
      </a>
    </th>
    <th><a href="https://www.technation.sucks">Tech Nation Visa Sucks</a></th>
  </tr>
</table>

<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/-1.svg?sanitize=true"></a></p>

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