Package Exports
- @wrote/ensure-path
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@wrote/ensure-path) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@wrote/ensure-path
@wrote/ensure-path
Creates All Directories On The Way To The Path.
yarn add -E @wrote/ensure-path
Table Of Contents
API
The package is available by importing its default function:
import ensurePath from '@wrote/ensure-path'
async ensurePath(
path: string,
): 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.
/* yarn example */
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
})()
Copyright
(c) Wrote 2019