@wrote/rm

1.1.5 • Public • Published

@wrote/rm

npm version

@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:
{}

Copyright

Art Deco © Art Deco for Wrote 2019 Wrote Tech Nation Visa Tech Nation Visa Sucks

Package Sidebar

Install

npm i @wrote/rm

Weekly Downloads

4

Version

1.1.5

License

MIT

Unpacked Size

8.87 kB

Total Files

9

Last publish

Collaborators

  • zvr