$ gnpm install @wrote/rm
@wrote/rm is a package to remove files and directories.
yarn add -E @wrote/rm
The package is available by importing its default function:
import rm from '@wrote/rm'
rm(path: string,): voidRemoves 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:
{}
      
         
      
     | 
    © Art Deco for Wrote 2019 | 
      
         | 
    
      
         
      
     | 
    Tech Nation Visa Sucks | 
|---|
Copyright 2013 - present © cnpmjs.org | Home |