Skip to content

Commit cc399fe

Browse files
committedMay 29, 2019
Drop support for macOS 10.11 and older
1 parent 8ec3260 commit cc399fe

File tree

4 files changed

+4
-34
lines changed

4 files changed

+4
-34
lines changed
 

‎lib/linux.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ DeletionDate=${(new Date()).toISOString()}
3838
};
3939
};
4040

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

‎lib/macos.js

+1-28
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,16 @@ const {promisify} = require('util');
33
const os = require('os');
44
const path = require('path');
55
const {execFile} = require('child_process');
6-
const escapeStringApplescript = require('escape-string-applescript');
7-
const runApplescript = require('run-applescript');
86

97
const isOlderThanMountainLion = Number(os.release().split('.')[0]) < 12;
108
const pExecFile = promisify(execFile);
119

1210
// Binary source: https://github.com/sindresorhus/macos-trash
1311
const binary = path.join(__dirname, 'macos-trash');
1412

15-
const legacy = async paths => {
16-
const pathString = paths.map(x => `"${escapeStringApplescript(x)}"`).join(',');
17-
18-
const script = `
19-
set deleteList to {}
20-
repeat with currentPath in {${pathString}}
21-
set end of deleteList to POSIX file currentPath
22-
end repeat
23-
tell app "Finder" to delete deleteList
24-
`.trim();
25-
26-
try {
27-
await runApplescript(script);
28-
} catch (error) {
29-
let newError = error;
30-
31-
if (/10010/.test(newError.message)) {
32-
newError = new Error('Item doesn\'t exist');
33-
}
34-
35-
throw newError;
36-
}
37-
};
38-
3913
module.exports = async paths => {
4014
if (isOlderThanMountainLion) {
41-
await legacy(paths);
42-
return;
15+
throw new Error('macOS 10.12 or later required');
4316
}
4417

4518
await pExecFile(binary, paths);

‎package.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,26 @@
3232
"del",
3333
"file",
3434
"files",
35-
"dir",
3635
"directory",
3736
"directories",
3837
"folder",
3938
"folders",
4039
"xdg"
4140
],
4241
"dependencies": {
43-
"escape-string-applescript": "^2.0.0",
4442
"globby": "^7.1.1",
4543
"is-path-inside": "^2.0.0",
4644
"make-dir": "^3.0.0",
4745
"move-file": "^1.1.0",
4846
"p-map": "^2.0.0",
4947
"p-try": "^2.2.0",
50-
"run-applescript": "^3.2.0",
5148
"uuid": "^3.3.2",
5249
"xdg-trashdir": "^2.1.1"
5350
},
5451
"devDependencies": {
5552
"ava": "^1.4.1",
5653
"tempfile": "^3.0.0",
57-
"tsd": "^0.7.1",
54+
"tsd": "^0.7.3",
5855
"xo": "^0.24.0"
5956
}
6057
}

‎readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
[![Build Status](https://travis-ci.org/sindresorhus/trash.svg?branch=master)](https://travis-ci.org/sindresorhus/trash)
66

7-
Works on macOS, Linux, and Windows (8 or later).
7+
Works on macOS (10.12+), Linux, and Windows (8+).
88

99
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.
1010

0 commit comments

Comments
 (0)
Please sign in to comment.