-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow deleting tons of files on macOS and Windows (#113)
Co-authored-by: Sindre Sorhus <[email protected]>
- Loading branch information
1 parent
f61611f
commit 5606166
Showing
4 changed files
with
18 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const {promisify} = require('util'); | ||
const {execFile} = require('child_process'); | ||
|
||
const pExecFile = promisify(execFile); | ||
|
||
module.exports = async (binary, paths, maxPaths) => { | ||
// TODO: Use https://github.com/sindresorhus/chunkify when targeting Node.js 12. | ||
for (let group = 0; paths.length > group; group += maxPaths) { | ||
// eslint-disable-next-line no-await-in-loop | ||
await pExecFile(binary, paths.slice(group, group + maxPaths)); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
'use strict'; | ||
const {promisify} = require('util'); | ||
const path = require('path'); | ||
const {execFile} = require('child_process'); | ||
|
||
const pExecFile = promisify(execFile); | ||
const chunkedExec = require('./chunked-exec'); | ||
|
||
// Binary source: https://github.com/sindresorhus/recycle-bin | ||
const binary = path.join(__dirname, 'windows-trash.exe'); | ||
|
||
module.exports = async paths => { | ||
await pExecFile(binary, paths); | ||
await chunkedExec(binary, paths, 200); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters