Comparing version 5.2.0 to 6.0.0
@@ -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. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
52335
8
11
135
4
- Removedescape-string-applescript@^2.0.0
- Removedrun-applescript@^3.2.0
- Removedcross-spawn@6.0.5(transitive)
- Removedescape-string-applescript@2.0.0(transitive)
- Removedexeca@0.10.0(transitive)
- Removedget-stream@3.0.0(transitive)
- Removedis-stream@1.1.0(transitive)
- Removedmake-dir@1.3.0(transitive)
- Removednice-try@1.0.5(transitive)
- Removednpm-run-path@2.0.2(transitive)
- Removedp-finally@1.0.0(transitive)
- Removedpath-key@2.0.1(transitive)
- Removedrun-applescript@3.2.0(transitive)
- Removedshebang-command@1.2.0(transitive)
- Removedshebang-regex@1.0.0(transitive)
- Removedsignal-exit@3.0.7(transitive)
Updatedmake-dir@^3.0.0