poof 2.2.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +165 -227
- package/dist/cli.mjs +842 -0
- package/dist/index.mjs +1854 -0
- package/dist/spawn-rm/worker.mjs +41 -0
- package/package.json +19 -57
- package/dist/index.js +0 -9
- package/lib/index.js +0 -4
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
|
|
4
|
+
const CONCURRENCY = 16;
|
|
5
|
+
const MAX_RETRIES = 3;
|
|
6
|
+
const RETRY_DELAY = 100;
|
|
7
|
+
async function* parseNullDelimitedPaths(stream) {
|
|
8
|
+
let buffer = Buffer.alloc(0);
|
|
9
|
+
for await (const chunk of stream) {
|
|
10
|
+
buffer = Buffer.concat([buffer, chunk]);
|
|
11
|
+
let nullIndex = buffer.indexOf(0);
|
|
12
|
+
while (nullIndex !== -1) {
|
|
13
|
+
const filePath = buffer.subarray(0, nullIndex);
|
|
14
|
+
if (filePath.length > 0) {
|
|
15
|
+
yield filePath;
|
|
16
|
+
}
|
|
17
|
+
buffer = buffer.subarray(nullIndex + 1);
|
|
18
|
+
nullIndex = buffer.indexOf(0);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (buffer.length > 0) {
|
|
22
|
+
yield buffer;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const pool = /* @__PURE__ */ new Set();
|
|
26
|
+
for await (const filePath of parseNullDelimitedPaths(process.stdin)) {
|
|
27
|
+
const task = fs.rm(filePath, {
|
|
28
|
+
recursive: true,
|
|
29
|
+
force: true,
|
|
30
|
+
maxRetries: MAX_RETRIES,
|
|
31
|
+
retryDelay: RETRY_DELAY
|
|
32
|
+
}).catch(() => {
|
|
33
|
+
}).then(() => {
|
|
34
|
+
pool.delete(task);
|
|
35
|
+
});
|
|
36
|
+
pool.add(task);
|
|
37
|
+
if (pool.size >= CONCURRENCY) {
|
|
38
|
+
await Promise.race(pool);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
await Promise.all(pool);
|
package/package.json
CHANGED
|
@@ -1,64 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "poof",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"jsnext:main": "lib/index.js",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist/index.js",
|
|
9
|
-
"lib/**/*.js"
|
|
10
|
-
],
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Fast, non-blocking rm -rf alternative. Deletes files instantly while cleanup runs in the background.",
|
|
11
5
|
"keywords": [
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"validator"
|
|
6
|
+
"rm",
|
|
7
|
+
"rimraf",
|
|
8
|
+
"delete",
|
|
9
|
+
"remove",
|
|
10
|
+
"fast",
|
|
11
|
+
"cli"
|
|
19
12
|
],
|
|
20
|
-
"homepage": "https://github.com/fatfisz/poof",
|
|
21
|
-
"repository": "https://github.com/fatfisz/poof.git",
|
|
22
|
-
"author": {
|
|
23
|
-
"name": "FatFisz",
|
|
24
|
-
"url": "https://github.com/fatfisz"
|
|
25
|
-
},
|
|
26
13
|
"license": "MIT",
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"eslint": "~2.9.0",
|
|
36
|
-
"eslint-config-fatfisz": "~2.9.0",
|
|
37
|
-
"grunt": "^1.0.1",
|
|
38
|
-
"grunt-babel": "^5.0.3",
|
|
39
|
-
"grunt-cli": "^1.2.0",
|
|
40
|
-
"grunt-contrib-clean": "^1.0.0",
|
|
41
|
-
"grunt-eslint": "^18.1.0",
|
|
42
|
-
"grunt-mocha-test": "^0.12.7",
|
|
43
|
-
"grunt-rollup": "^0.7.1",
|
|
44
|
-
"load-grunt-tasks": "^3.5.0",
|
|
45
|
-
"mocha": "^2.5.3",
|
|
46
|
-
"mockery": "^1.7.0",
|
|
47
|
-
"rollup-plugin-babel": "^1.0.0",
|
|
48
|
-
"should": "^8.4.0",
|
|
49
|
-
"should-sinon": "0.0.5",
|
|
50
|
-
"sinon": "^2.0.0-pre"
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"type": "module",
|
|
18
|
+
"bin": "./dist/cli.mjs",
|
|
19
|
+
"exports": "./dist/index.mjs",
|
|
20
|
+
"imports": {
|
|
21
|
+
"#rm-worker": "./dist/spawn-rm/worker.mjs"
|
|
51
22
|
},
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"es6.classes",
|
|
55
|
-
"es6.destructuring",
|
|
56
|
-
"es6.forOf",
|
|
57
|
-
"es6.properties.computed",
|
|
58
|
-
"es6.spread"
|
|
59
|
-
],
|
|
60
|
-
"optional": [
|
|
61
|
-
"es7.decorators"
|
|
62
|
-
]
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=20.8.0"
|
|
63
25
|
}
|
|
64
|
-
}
|
|
26
|
+
}
|
package/dist/index.js
DELETED
package/lib/index.js
DELETED