Socket
Socket
Sign inDemoInstall

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 7.0.0 to 7.1.0

lib/chunked-exec.js

43

index.js

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

const globby = require('globby');
const pTry = require('p-try');
const isPathInside = require('is-path-inside');
const macos = require('./lib/macos');
const linux = require('./lib/linux');
const windows = require('./lib/windows');
const trash = (paths, options) => pTry(() => {
const trash = async (paths, options) => {
paths = (typeof paths === 'string' ? [paths] : paths).map(path => String(path));

@@ -22,3 +18,3 @@

if (options.glob) {
paths = globby.sync(paths, {
paths = await globby(paths, {
expandDirectories: false,

@@ -30,14 +26,13 @@ nodir: false,

paths = paths.map(filePath => path.resolve(filePath));
paths = paths.filter(filePath => {
paths = await Promise.all(paths.map(async filePath => {
if (paths.some(otherPath => isPathInside(filePath, otherPath))) {
return false;
return;
}
try {
return fs.lstatSync(filePath);
// eslint-disable-next-line node/no-unsupported-features/node-builtins -- It's Node 10.1+
await fs.promises.lstat(filePath);
} catch (error) {
if (error.code === 'ENOENT') {
return false;
return;
}

@@ -47,4 +42,8 @@

}
});
return path.resolve(filePath);
}));
paths = paths.filter(isPath => isPath);
if (paths.length === 0) {

@@ -54,12 +53,14 @@ return;

switch (process.platform) {
case 'darwin':
return macos(paths);
case 'win32':
return windows(paths);
default:
return linux(paths);
let trash;
if (process.platform === 'darwin') {
trash = require('./lib/macos');
} else if (process.platform === 'win32') {
trash = require('./lib/windows');
} else {
trash = require('./lib/linux');
}
});
return trash(paths);
};
module.exports = trash;
'use strict';
const {promisify} = require('util');
const os = require('os');
const path = require('path');
const {execFile} = require('child_process');
const chunkedExec = require('./chunked-exec');
const isOlderThanMountainLion = Number(os.release().split('.')[0]) < 12;
const pExecFile = promisify(execFile);

@@ -18,3 +16,3 @@ // Binary source: https://github.com/sindresorhus/macos-trash

await pExecFile(binary, paths);
await chunkedExec(binary, paths, 1000);
};
'use strict';
const {promisify} = require('util');
const path = require('path');
const {execFile} = require('child_process');
const chunkedExec = require('./chunked-exec');
const pExecFile = promisify(execFile);
// Binary source: https://github.com/sindresorhus/recycle-bin

@@ -12,3 +9,3 @@ const binary = path.join(__dirname, 'windows-trash.exe');

module.exports = async paths => {
await pExecFile(binary, paths);
await chunkedExec(binary, paths, 200);
};
{
"name": "trash",
"version": "7.0.0",
"version": "7.1.0",
"description": "Move files and folders to the trash",

@@ -49,4 +49,3 @@ "license": "MIT",

"p-map": "^4.0.0",
"p-try": "^2.2.0",
"uuid": "^8.3.1",
"uuid": "^8.3.2",
"xdg-trashdir": "^3.1.0"

@@ -57,5 +56,5 @@ },

"tempfile": "^3.0.0",
"tsd": "^0.13.1",
"xo": "^0.35.0"
"tsd": "^0.14.0",
"xo": "^0.37.1"
}
}

@@ -5,4 +5,2 @@ # ![trash](media/logo.svg)

[![Build Status](https://travis-ci.com/sindresorhus/trash.svg?branch=master)](https://travis-ci.com/github/sindresorhus/trash)
Works on macOS (10.12+), Linux, and Windows (8+).

@@ -64,3 +62,3 @@

On macOS, [`macos-trash`](https://github.com/sindresorhus/macos-trash) is used.\
On Linux, the [XDG spec](http://standards.freedesktop.org/trash-spec/trashspec-1.0.html) is followed.\
On Linux, the [XDG spec](https://standards.freedesktop.org/trash-spec/trashspec-1.0.html) is followed.\
On Windows, [`recycle-bin`](https://github.com/sindresorhus/recycle-bin) is used.

@@ -72,3 +70,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 macOS, you'll lose 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](https://standards.freedesktop.org/trash-spec/trashspec-1.0.html) you need to follow. On macOS, you'll lose the [Put back](https://mac-fusion.com/trash-tip-how-to-put-files-back-to-their-original-location/) feature.

@@ -75,0 +73,0 @@ ## Related

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