Socket
Socket
Sign inDemoInstall

trash

Package Overview
Dependencies
Maintainers
2
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trash - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

42

package.json
{
"name": "trash",
"version": "2.0.0",
"description": "Cross-platform command-line app for moving files and directories to the trash - A safer alternative to `rm`",
"version": "3.0.0",
"description": "Move files and directories to the trash",
"license": "MIT",

@@ -12,4 +12,2 @@ "repository": "sindresorhus/trash",

},
"bin": "cli.js",
"preferGlobal": true,
"engines": {

@@ -19,17 +17,17 @@ "node": ">=0.10.0"

"scripts": {
"test": "mocha"
"test": "xo && ava"
},
"files": [
"index.js",
"cli.js"
"index.js"
],
"keywords": [
"cli-app",
"cli",
"bin",
"trash",
"recycle",
"bin",
"rm",
"rmrf",
"rimraf",
"remove",
"delete",
"del",
"file",

@@ -40,18 +38,20 @@ "files",

"directories",
"shell",
"script"
"xdg"
],
"dependencies": {
"each-async": "^1.1.1",
"meow": "^3.0.0",
"osx-trash": "^1.0.1",
"path-exists": "^1.0.0",
"update-notifier": "^0.3.0",
"win-trash": "^1.0.1",
"xdg-trash": "^1.0.0"
"osx-trash": "^2.0.0",
"win-trash": "^2.0.0",
"xdg-trash": "^2.0.1"
},
"devDependencies": {
"mocha": "*",
"path-exists": "^1.0.0"
"ava": "*",
"path-exists": "^2.0.0",
"tempfile": "^1.1.1",
"xo": "*"
},
"xo": {
"ignore": [
"test.js"
]
}
}

@@ -1,42 +0,25 @@

# ![trash](https://cdn.rawgit.com/sindresorhus/trash/3aa70853f1efb58d0d2512e32d617d246c88953c/media/logo.svg)
# ![trash](https://cdn.rawgit.com/sindresorhus/trash/1cdbd660976d739eeb45447bb6b62c41ac4a3ecf/media/logo.svg)
> Cross-platform command-line app for moving files and directories to the trash
> A safer alternative to [`rm`](http://en.wikipedia.org/wiki/Rm_(Unix))
> Move files and directories to the trash
[![Build Status](https://travis-ci.org/sindresorhus/trash.svg?branch=master)](https://travis-ci.org/sindresorhus/trash) ![](http://img.shields.io/badge/unicorn-approved-ff69b4.svg)
[![Build Status](https://travis-ci.org/sindresorhus/trash.svg?branch=master)](https://travis-ci.org/sindresorhus/trash)
Works on OS X, Linux and Windows.
Works on OS X, Linux, and Windows.
In contrast to `rm` which is [dangerous](http://docstore.mik.ua/orelly/unix3/upt/ch14_03.htm) and permanently delete files, this only moves them to the trash, which is much safer and reversible. You should not alias `rm` to `trash` however as that would break most scripts relying on `rm` behaviour. Rather use `trash` from the CLI and in your own scripts. I would also recommend reading my guide on [safeguarding `rm`](https://github.com/sindresorhus/guides/blob/master/how-not-to-rm-yourself.md#safeguard-rm).
In contrast to [`fs.unlink`](https://nodejs.org/api/fs.html#fs_fs_unlink_path_callback), [`del`](https://github.com/sindresorhus/del), and [`rimraf`](https://github.com/isaacs/rimraf) which permanently delete files, this only moves them to the trash, which is much safer and reversible.
## CLI
## Install
```
$ npm install --global trash
$ npm install --save trash
```
```
$ trash --help
Usage
$ trash <path> [<path> ...]
## Usage
Example
$ trash unicorn.png rainbow.png
```
*Globbing support is left up to your shell, but `$ trash *.png` should expand to the above in most shells.*
## API
```
$ npm install --save trash
```
```js
var trash = require('trash');
const trash = require('trash');
trash(['unicorn.png', 'rainbow.png'], function (err) {
trash(['unicorn.png', 'rainbow.png']).then(() => {
console.log('done');

@@ -49,14 +32,9 @@ });

On OS X [`osx-trash`](https://github.com/sindresorhus/osx-trash) is used.
On OS X, [`osx-trash`](https://github.com/sindresorhus/osx-trash) is used.
On Linux [`xdg-trash`](https://github.com/kevva/xdg-trash) is used.
On Linux, [`xdg-trash`](https://github.com/kevva/xdg-trash) is used.
On Windows [`cmdutils`](http://www.maddogsw.com/cmdutils/) is used.
On Windows, [`cmdutils`](http://www.maddogsw.com/cmdutils/) is used.
## Tip
Add `alias t=trash` to your `.zshrc`/`.bashrc` to reduce typing: `$ t unicorn.png`.
## FAQ

@@ -66,3 +44,3 @@

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](http://www.ramendik.ru/docs/trashspec.html) you need to follow. On OS X you'll loose the [Put back](http://mac-fusion.com/trash-tip-how-to-put-files-back-to-their-original-location/) feature.
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](http://www.ramendik.ru/docs/trashspec.html) you need to follow. On OS X, you'll lose the [Put back](http://mac-fusion.com/trash-tip-how-to-put-files-back-to-their-original-location/) feature.

@@ -72,3 +50,5 @@

See [`empty-trash`](https://github.com/sindresorhus/empty-trash) for emptying the trash.
- [trash-cli](https://github.com/sindresorhus/trash-cli) - CLI for this module
- [empty-trash](https://github.com/sindresorhus/empty-trash) - Empty the trash
- [del](https://github.com/sindresorhus/del) - Delete files/folders using globs

@@ -75,0 +55,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc