A package to remove files and directories.
npm install @wrote/rm
@wrote/rm is a package to remove files and directories.
``sh`
yarn add -E @wrote/rm
- Table Of Contents
- API
- rm(path: string)
- Copyright
The package is available by importing its default function:
`js`
import rm from '@wrote/rm'
path: string,
): voidRemoves a path to either a file or directory.
`js
/ yarn example/ /
import rm from '@wrote/rm'
import clone from '@wrote/clone'
import readDirStructure from '@wrote/read-dir-structure'
const printContent = async (p) => {
const { content } = await readDirStructure(p)
console.log(JSON.stringify(content, null, 2))
}
(async () => {
// 0. SETUP: create a temp directory to remove.
await clone('example/dir', 'example/temp')
console.log('Content before:')
await printContent('example/temp')
// 1. REMOVE the directory.
await rm('example/temp/dir')
// 2. VALIDATE the removal.
console.log('Content after:')
await printContent('example/temp')
})()
`
```
Content before:
{
"dir": {
"content": {
"example.txt": {
"type": "File"
}
},
"type": "Directory"
}
}
Content after:
{}
![]() | © Art Deco for Wrote 2019 | alt="Tech Nation Visa" /> | Tech Nation Visa Sucks |
|---|