RFC-OPEN-PATH
Node module that creates missing folders in the middle of a path, like mkdir -p
.
DEPRECATED: See @fcostarodrigo/open-path
Description
Let's say you want to create the file docs/UI/button.txt
, but the folders UI
and docs
don't exist.
If you just try to create the file, this happens:
> fsThrown: Error: ENOENT: no such file or directory open 'docs/UI/button.txt' at Object at Object errno: -2 syscall: 'open' code: 'ENOENT' path: 'docs/UI/button.txt'
If you try to create the folder you get this:
> fsThrown: Error: ENOENT: no such file or directory mkdir 'docs/UI' at Object errno: -2 syscall: 'mkdir' code: 'ENOENT' path: 'docs/UI'
Using this library you can create the inner folders easily:
const openPath = ; ;
Installation
npm install rfc-open-path
Usage
const openPath = ;
Callbacks
;
Promises
;
Async await
{ await ; fs;}
CLI
rfc-open-path --help
Documentation
;
pathToOpen
: String with the path.fileInPath
: Indicates if the last item of the path is a file.callback
: Called after the directories were created or after an error.promise
: Resolves to nothing after the directories are created or rejects with an error.
Development
Full tests with coverage
npm test
Unit tests and watch for changes
npm run unit-test