@wrote/rm
v1.1.5
Published
A package to remove files and directories.
Downloads
241
Maintainers
Readme
@wrote/rm
@wrote/rm
is a package to remove files and directories.
yarn add -E @wrote/rm
Table Of Contents
API
The package is available by importing its default function:
import rm from '@wrote/rm'
rm(
path: string,
): void
Removes a path to either a file or directory.
/* 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:
{}