Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

trash

Package Overview
Dependencies
Maintainers
1
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 5.2.0 to 6.0.0

lib/.DS_Store

37

index.d.ts

@@ -12,28 +12,21 @@ declare namespace trash {

declare const trash: {
/**
Move files and folders to the trash.
/**
Move files and folders to the trash.
@param input - Accepts paths and [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
@param input - Accepts paths and [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
@example
```
import trash = require('trash');
@example
```
import trash = require('trash');
(async () => {
await trash(['*.png', '!rainbow.png']);
})();
```
*/
(input: string | string[], options?: trash.Options): Promise<void>;
(async () => {
await trash(['*.png', '!rainbow.png']);
})();
```
*/
declare function trash(
input: string | readonly string[],
options?: trash.Options
): Promise<void>;
// TODO: Remove this for the next major release, refactor the whole definition to:
// declare function trash(
// input: string | string[],
// options?: Options
// ): Promise<void>;
// export = trash;
default: typeof trash;
};
export = trash;

@@ -60,3 +60,1 @@ 'use strict';

module.exports = trash;
// TODO: Remove this for the next major release
module.exports.default = trash;

@@ -41,2 +41,2 @@ 'use strict';

module.exports = paths => pMap(paths, trash, {concurrency: os.cpus().length});
module.exports = async paths => pMap(paths, trash, {concurrency: os.cpus().length});

@@ -6,4 +6,2 @@ 'use strict';

const {execFile} = require('child_process');
const escapeStringApplescript = require('escape-string-applescript');
const runApplescript = require('run-applescript');

@@ -16,30 +14,5 @@ const isOlderThanMountainLion = Number(os.release().split('.')[0]) < 12;

const legacy = async paths => {
const pathString = paths.map(x => `"${escapeStringApplescript(x)}"`).join(',');
const script = `
set deleteList to {}
repeat with currentPath in {${pathString}}
set end of deleteList to POSIX file currentPath
end repeat
tell app "Finder" to delete deleteList
`.trim();
try {
await runApplescript(script);
} catch (error) {
let newError = error;
if (/10010/.test(newError.message)) {
newError = new Error('Item doesn\'t exist');
}
throw newError;
}
};
module.exports = async paths => {
if (isOlderThanMountainLion) {
await legacy(paths);
return;
throw new Error('macOS 10.12 or later required');
}

@@ -46,0 +19,0 @@

@@ -9,3 +9,3 @@ 'use strict';

// Binary source: https://github.com/sindresorhus/recycle-bin
const binary = path.join(__dirname, 'win-trash.exe');
const binary = path.join(__dirname, 'windows-trash.exe');

@@ -12,0 +12,0 @@ module.exports = async paths => {

{
"name": "trash",
"version": "5.2.0",
"version": "6.0.0",
"description": "Move files and folders to the trash",

@@ -35,3 +35,2 @@ "license": "MIT",

"files",
"dir",
"directory",

@@ -44,10 +43,8 @@ "directories",

"dependencies": {
"escape-string-applescript": "^2.0.0",
"globby": "^7.1.1",
"is-path-inside": "^2.0.0",
"make-dir": "^1.3.0",
"make-dir": "^3.0.0",
"move-file": "^1.1.0",
"p-map": "^2.0.0",
"p-try": "^2.2.0",
"run-applescript": "^3.2.0",
"uuid": "^3.3.2",

@@ -58,6 +55,6 @@ "xdg-trashdir": "^2.1.1"

"ava": "^1.4.1",
"tempfile": "^2.0.0",
"tsd": "^0.7.1",
"tempfile": "^3.0.0",
"tsd": "^0.7.3",
"xo": "^0.24.0"
}
}

@@ -7,3 +7,3 @@ # ![trash](media/logo.svg)

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

@@ -10,0 +10,0 @@ 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.

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