All Projects → sindresorhus → Trash

sindresorhus / Trash

Licence: mit
Move files and directories to the trash

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Trash

rmw
a safe-remove utility for the command line
Stars: ✭ 48 (-97.91%)
Mutual labels:  trash, recycle-bin
wastebasket
A crossplatform go library for moving files to the trashbin
Stars: ✭ 30 (-98.69%)
Mutual labels:  trash, delete
Into Stream
Convert a string/promise/array/iterable/asynciterable/buffer/typedarray/arraybuffer/object into a stream
Stars: ✭ 167 (-92.72%)
Mutual labels:  npm-package
React Sticky El
Stars: ✭ 179 (-92.19%)
Mutual labels:  npm-package
Slugify
Slugify a string
Stars: ✭ 2,110 (-7.98%)
Mutual labels:  npm-package
Reactopt
A CLI React performance optimization tool that identifies potential unnecessary re-rendering
Stars: ✭ 1,975 (-13.87%)
Mutual labels:  npm-package
Gulp Traceur
Traceur is a JavaScript.next to JavaScript-of-today compiler
Stars: ✭ 172 (-92.5%)
Mutual labels:  npm-package
Magic Iterable
Call a method on all items in an iterable by calling it on the iterable itself
Stars: ✭ 159 (-93.07%)
Mutual labels:  npm-package
Angular Tslint Rules
Shared TSLint & codelyzer rules to enforce a consistent code style for Angular development
Stars: ✭ 181 (-92.11%)
Mutual labels:  npm-package
Yocto Queue
Tiny queue data structure
Stars: ✭ 171 (-92.54%)
Mutual labels:  npm-package
Feathericon
simply generic vector icon collection - including sketch file, svg files, and font files.
Stars: ✭ 178 (-92.24%)
Mutual labels:  npm-package
Http Loader
A loader for ngx-translate that loads translations with http calls
Stars: ✭ 170 (-92.59%)
Mutual labels:  npm-package
Cash Cli
💰💰 Convert currency rates directly from your terminal!
Stars: ✭ 168 (-92.67%)
Mutual labels:  npm-package
Express Prom Bundle
express middleware with standard prometheus metrics in one bundle
Stars: ✭ 172 (-92.5%)
Mutual labels:  npm-package
Typescript Transform Paths
Transforms absolute imports to relative
Stars: ✭ 166 (-92.76%)
Mutual labels:  npm-package
Node Regedit
Read, Write, List and do all sorts of funky stuff to the windows registry using node.js and windows script host
Stars: ✭ 178 (-92.24%)
Mutual labels:  npm-package
Alfred Dark Mode
Alfred 3 workflow to toggle the system dark mode
Stars: ✭ 165 (-92.8%)
Mutual labels:  npm-package
New Github Issue Url
Generate a URL for opening a new GitHub issue with prefilled title, body, and other fields
Stars: ✭ 170 (-92.59%)
Mutual labels:  npm-package
File Icon Vectors
A collection of file type icons in SVG format
Stars: ✭ 171 (-92.54%)
Mutual labels:  npm-package
Blynk Library Js
Blynk library for JS. Works with Browsers, Node.js, Espruino.
Stars: ✭ 181 (-92.11%)
Mutual labels:  npm-package

trash

Move files and folders to the trash

Works on macOS (10.12+), Linux, and Windows (8+).

Note: The Linux implementation is not very good and not maintained. Help welcome. If no one steps up to help maintain it, I will eventually remove Linux support.

In contrast to fs.unlink, del, and rimraf which permanently delete files, this only moves them to the trash, which is much safer and reversible.

Install

npm install trash

Usage

import trash from 'trash';

await trash(['*.png', '!rainbow.png']);

API

trash(input, options?)

Returns a Promise.

input

Type: string | string[]

Accepts paths and glob patterns.

options

Type: object

glob

Type: boolean
Default: true

Enable globbing when matching file paths.

CLI

To install the trash command, run:

$ npm install --global trash-cli

Info

On macOS, macos-trash is used.
On Linux, the XDG spec is followed.
On Windows, recycle-bin is used.

FAQ

But I can do the same thing with mv

Not really. The mv command isn't cross-platform and moving to trash is not just about moving the file to a "trash" directory. On all OSes you'll run into file conflicts. The user won't easily be able to restore the file. It won't work on an external drive. The trash directory location varies between Windows versions. For Linux, there's a whole spec you need to follow. On macOS, you'll lose the Put back feature.

Related

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].