Comparing version 4.2.0 to 4.3.0
{ | ||
"name": "rimraf", | ||
"version": "4.2.0", | ||
"version": "4.3.0", | ||
"main": "./dist/cjs/src/index-cjs.js", | ||
@@ -60,3 +60,3 @@ "module": "./dist/mjs/index.js", | ||
"prettier": "^2.8.2", | ||
"tap": "^16.3.3", | ||
"tap": "^16.3.4", | ||
"ts-node": "^10.9.1", | ||
@@ -63,0 +63,0 @@ "typedoc": "^0.23.21", |
@@ -17,25 +17,100 @@ #!/usr/bin/env node | ||
Options: | ||
-- Treat all subsequent arguments as paths | ||
-h --help Display this usage info | ||
--preserve-root Do not remove '/' recursively (default) | ||
--no-preserve-root Do not treat '/' specially | ||
-G --no-glob Treat arguments as literal paths, not globs (default) | ||
-g --glob Treat arguments as glob patterns | ||
-- Treat all subsequent arguments as paths | ||
-h --help Display this usage info | ||
--preserve-root Do not remove '/' recursively (default) | ||
--no-preserve-root Do not treat '/' specially | ||
-G --no-glob Treat arguments as literal paths, not globs (default) | ||
-g --glob Treat arguments as glob patterns | ||
-v --verbose Be verbose when deleting files, showing them as | ||
they are removed. Not compatible with --impl=native | ||
-V --no-verbose Be silent when deleting files, showing nothing as | ||
they are removed (default) | ||
-i --interactive Ask for confirmation before deleting anything | ||
Not compatible with --impl=native | ||
-I --no-interactive Do not ask for confirmation before deleting | ||
--impl=<type> Specify the implementation to use. | ||
rimraf: choose the best option | ||
native: the built-in implementation in Node.js | ||
manual: the platform-specific JS implementation | ||
posix: the Posix JS implementation | ||
windows: the Windows JS implementation | ||
move-remove: a slower Windows JS fallback implementation | ||
--impl=<type> Specify the implementation to use: | ||
rimraf: choose the best option (default) | ||
native: the built-in implementation in Node.js | ||
manual: the platform-specific JS implementation | ||
posix: the Posix JS implementation | ||
windows: the Windows JS implementation (falls back to | ||
move-remove on ENOTEMPTY) | ||
move-remove: a slow reliable Windows fallback | ||
Implementation-specific options: | ||
--tmp=<path> Folder to hold temp files for 'move-remove' implementation | ||
--max-retries=<n> maxRetries for the 'native' and 'windows' implementations | ||
--retry-delay=<n> retryDelay for the 'native' implementation, default 100 | ||
--tmp=<path> Temp file folder for 'move-remove' implementation | ||
--max-retries=<n> maxRetries for 'native' and 'windows' implementations | ||
--retry-delay=<n> retryDelay for 'native' implementation, default 100 | ||
--backoff=<n> Exponential backoff factor for retries (default: 1.2) | ||
`; | ||
const path_1 = require("path"); | ||
const cwd = process.cwd(); | ||
const readline_1 = require("readline"); | ||
const prompt = async (rl, q) => new Promise(res => rl.question(q, res)); | ||
const interactiveRimraf = async (impl, paths, opt) => { | ||
const existingFilter = opt.filter || (() => true); | ||
let allRemaining = false; | ||
let noneRemaining = false; | ||
const queue = []; | ||
let processing = false; | ||
const processQueue = async () => { | ||
if (processing) | ||
return; | ||
processing = true; | ||
let next; | ||
while ((next = queue.shift())) { | ||
await next(); | ||
} | ||
processing = false; | ||
}; | ||
const oneAtATime = (fn) => async (s) => { | ||
const p = new Promise(res => { | ||
queue.push(async () => { | ||
const result = await fn(s); | ||
res(result); | ||
return result; | ||
}); | ||
}); | ||
processQueue(); | ||
return p; | ||
}; | ||
const rl = (0, readline_1.createInterface)({ | ||
input: process.stdin, | ||
output: process.stdout, | ||
}); | ||
opt.filter = oneAtATime(async (path) => { | ||
if (noneRemaining) { | ||
return false; | ||
} | ||
while (!allRemaining) { | ||
const a = (await prompt(rl, `rm? ${(0, path_1.relative)(cwd, path)}\n[(Yes)/No/All/Quit] > `)).trim(); | ||
if (/^n/i.test(a)) { | ||
return false; | ||
} | ||
else if (/^a/i.test(a)) { | ||
allRemaining = true; | ||
break; | ||
} | ||
else if (/^q/i.test(a)) { | ||
noneRemaining = true; | ||
return false; | ||
} | ||
else if (a === '' || /^y/i.test(a)) { | ||
break; | ||
} | ||
else { | ||
continue; | ||
} | ||
} | ||
return existingFilter(path); | ||
}); | ||
await impl(paths, opt); | ||
rl.close(); | ||
}; | ||
const main = async (...args) => { | ||
const verboseFilter = (s) => { | ||
console.log((0, path_1.relative)(cwd, s)); | ||
return true; | ||
}; | ||
if (process.env.__RIMRAF_TESTING_BIN_FAIL__ === '1') { | ||
@@ -48,2 +123,3 @@ throw new Error('simulated rimraf failure'); | ||
let impl = index_cjs_js_1.default; | ||
let interactive = false; | ||
for (const arg of args) { | ||
@@ -66,2 +142,18 @@ if (dashdash) { | ||
} | ||
else if (arg === '--interactive' || arg === '-i') { | ||
interactive = true; | ||
continue; | ||
} | ||
else if (arg === '--no-interactive' || arg === '-I') { | ||
interactive = false; | ||
continue; | ||
} | ||
else if (arg === '--verbose' || arg === '-v') { | ||
opt.filter = verboseFilter; | ||
continue; | ||
} | ||
else if (arg === '--no-verbose' || arg === '-V') { | ||
opt.filter = undefined; | ||
continue; | ||
} | ||
else if (arg === '-g' || arg === '--glob') { | ||
@@ -147,3 +239,13 @@ opt.glob = true; | ||
} | ||
await impl(paths, opt); | ||
if (impl === index_cjs_js_1.default.native && (interactive || opt.filter)) { | ||
console.error('native implementation does not support -v or -i'); | ||
runHelpForUsage(); | ||
return 1; | ||
} | ||
if (interactive) { | ||
await interactiveRimraf(impl, paths, opt); | ||
} | ||
else { | ||
await impl(paths, opt); | ||
} | ||
return 0; | ||
@@ -150,0 +252,0 @@ }; |
@@ -1,54 +0,54 @@ | ||
declare const _default: ((path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => Promise<void>) & { | ||
rimraf: ((path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
declare const _default: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise<boolean>) & { | ||
rimraf: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
}; | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
rimrafSync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
manual: ((path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
rimrafSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
manual: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
}; | ||
manualSync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
native: ((path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
manualSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
native: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
}; | ||
nativeSync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
posix: ((path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
nativeSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
posix: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
}; | ||
posixSync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
windows: ((path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
posixSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
windows: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
}; | ||
windowsSync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
moveRemove: ((path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
windowsSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
moveRemove: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
}; | ||
moveRemoveSync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
moveRemoveSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
} & { | ||
default: ((path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => Promise<void>) & { | ||
rimraf: ((path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
default: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise<boolean>) & { | ||
rimraf: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
}; | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
rimrafSync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
manual: ((path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
rimrafSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
manual: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
}; | ||
manualSync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
native: ((path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
manualSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
native: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
}; | ||
nativeSync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
posix: ((path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
nativeSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
posix: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
}; | ||
posixSync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
windows: ((path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
posixSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
windows: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
}; | ||
windowsSync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
moveRemove: ((path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
windowsSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
moveRemove: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
}; | ||
moveRemoveSync: (path: string | string[], opt?: import("./index.js").RimrafOptions | undefined) => void; | ||
moveRemoveSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean; | ||
}; | ||
@@ -55,0 +55,0 @@ }; |
import { GlobOptions } from 'glob'; | ||
export interface RimrafOptions { | ||
export interface RimrafAsyncOptions { | ||
preserveRoot?: boolean; | ||
@@ -11,55 +11,60 @@ tmp?: string; | ||
glob?: boolean | GlobOptions; | ||
filter?: ((path: string) => boolean) | ((path: string) => Promise<boolean>); | ||
} | ||
export interface RimrafSyncOptions extends RimrafAsyncOptions { | ||
filter?: (path: string) => boolean; | ||
} | ||
export type RimrafOptions = RimrafSyncOptions | RimrafAsyncOptions; | ||
export declare const isRimrafOptions: (o: any) => o is RimrafOptions; | ||
export declare const assertRimrafOptions: (o: any) => void; | ||
export declare const nativeSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const native: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const nativeSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
export declare const native: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
export declare const manualSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const manual: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const manualSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
export declare const manual: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
export declare const windowsSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const windows: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const windowsSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
export declare const windows: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
export declare const posixSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const posix: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const posixSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
export declare const posix: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
export declare const moveRemoveSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const moveRemove: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const moveRemoveSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
export declare const moveRemove: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
export declare const rimrafSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const rimraf: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
rimraf: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const rimrafSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
export declare const sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
export declare const rimraf: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
rimraf: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
rimrafSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
manual: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
rimrafSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
manual: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
manualSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
native: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
manualSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
native: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
nativeSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
posix: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
nativeSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
posix: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
posixSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
windows: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
posixSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
windows: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
windowsSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
moveRemove: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
windowsSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
moveRemove: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
moveRemoveSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
moveRemoveSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
export default rimraf; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -7,3 +7,3 @@ "use strict"; | ||
exports.rimraf = exports.sync = exports.rimrafSync = exports.moveRemove = exports.moveRemoveSync = exports.posix = exports.posixSync = exports.windows = exports.windowsSync = exports.manual = exports.manualSync = exports.native = exports.nativeSync = exports.assertRimrafOptions = exports.isRimrafOptions = void 0; | ||
const opt_arg_js_1 = __importDefault(require("./opt-arg.js")); | ||
const opt_arg_js_1 = require("./opt-arg.js"); | ||
const path_arg_js_1 = __importDefault(require("./path-arg.js")); | ||
@@ -20,3 +20,4 @@ const glob_1 = require("glob"); | ||
typeOrUndef(o.maxBackoff, 'number') && | ||
(typeOrUndef(o.glob, 'boolean') || (o.glob && typeof o.glob === 'object')); | ||
(typeOrUndef(o.glob, 'boolean') || (o.glob && typeof o.glob === 'object')) && | ||
typeOrUndef(o.filter, 'function'); | ||
exports.isRimrafOptions = isRimrafOptions; | ||
@@ -36,18 +37,26 @@ const assertRimrafOptions = (o) => { | ||
const wrap = (fn) => async (path, opt) => { | ||
const options = (0, opt_arg_js_1.default)(opt); | ||
const options = (0, opt_arg_js_1.optArg)(opt); | ||
if (options.glob) { | ||
path = await (0, glob_1.glob)(path, options.glob); | ||
} | ||
await (Array.isArray(path) | ||
? Promise.all(path.map(p => fn((0, path_arg_js_1.default)(p, options), options))) | ||
: fn((0, path_arg_js_1.default)(path, options), options)); | ||
if (Array.isArray(path)) { | ||
return !!(await Promise.all(path.map(p => fn((0, path_arg_js_1.default)(p, options), options)))).reduce((a, b) => a && b, true); | ||
} | ||
else { | ||
return !!(await fn((0, path_arg_js_1.default)(path, options), options)); | ||
} | ||
}; | ||
const wrapSync = (fn) => (path, opt) => { | ||
const options = (0, opt_arg_js_1.default)(opt); | ||
const options = (0, opt_arg_js_1.optArgSync)(opt); | ||
if (options.glob) { | ||
path = (0, glob_1.globSync)(path, options.glob); | ||
} | ||
return Array.isArray(path) | ||
? path.forEach(p => fn((0, path_arg_js_1.default)(p, options), options)) | ||
: fn((0, path_arg_js_1.default)(path, options), options); | ||
if (Array.isArray(path)) { | ||
return !!path | ||
.map(p => fn((0, path_arg_js_1.default)(p, options), options)) | ||
.reduce((a, b) => a && b, true); | ||
} | ||
else { | ||
return !!fn((0, path_arg_js_1.default)(path, options), options); | ||
} | ||
}; | ||
@@ -54,0 +63,0 @@ exports.nativeSync = wrapSync(rimraf_native_js_1.rimrafNativeSync); |
import { GlobOptions } from 'glob'; | ||
import { RimrafOptions } from './index.js'; | ||
declare const _default: (opt?: RimrafOptions) => RimrafOptions & { | ||
glob?: (GlobOptions & { | ||
import { RimrafAsyncOptions, RimrafSyncOptions } from './index.js'; | ||
export declare const optArg: (opt?: RimrafAsyncOptions) => (RimrafAsyncOptions & { | ||
glob: GlobOptions & { | ||
withFileTypes: false; | ||
}) | undefined; | ||
}; | ||
export default _default; | ||
}; | ||
}) | (RimrafAsyncOptions & { | ||
glob: undefined; | ||
}); | ||
export declare const optArgSync: (opt?: RimrafSyncOptions) => (RimrafSyncOptions & { | ||
glob: GlobOptions & { | ||
withFileTypes: false; | ||
}; | ||
}) | (RimrafSyncOptions & { | ||
glob: undefined; | ||
}); | ||
//# sourceMappingURL=opt-arg.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.optArgSync = exports.optArg = void 0; | ||
const index_js_1 = require("./index.js"); | ||
exports.default = (opt = {}) => { | ||
const optArgT = (opt) => { | ||
(0, index_js_1.assertRimrafOptions)(opt); | ||
const { glob, ...options } = opt; | ||
if (!glob) | ||
if (!glob) { | ||
return options; | ||
} | ||
const globOpt = glob === true | ||
@@ -30,2 +32,6 @@ ? opt.signal | ||
}; | ||
const optArg = (opt = {}) => optArgT(opt); | ||
exports.optArg = optArg; | ||
const optArgSync = (opt = {}) => optArgT(opt); | ||
exports.optArgSync = optArgSync; | ||
//# sourceMappingURL=opt-arg.js.map |
@@ -1,4 +0,4 @@ | ||
import { RimrafOptions } from './index.js'; | ||
declare const pathArg: (path: string, opt?: RimrafOptions) => string; | ||
import { RimrafAsyncOptions } from './index.js'; | ||
declare const pathArg: (path: string, opt?: RimrafAsyncOptions) => string; | ||
export default pathArg; | ||
//# sourceMappingURL=path-arg.d.ts.map |
@@ -6,5 +6,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const platform_js_1 = __importDefault(require("./platform.js")); | ||
const path_1 = require("path"); | ||
const util_1 = require("util"); | ||
const platform_js_1 = __importDefault(require("./platform.js")); | ||
const pathArg = (path, opt = {}) => { | ||
@@ -11,0 +11,0 @@ const type = typeof path; |
@@ -1,2 +0,2 @@ | ||
import { RimrafOptions } from '.'; | ||
import { RimrafAsyncOptions, RimrafOptions } from '.'; | ||
export declare const MAXBACKOFF = 200; | ||
@@ -6,4 +6,4 @@ export declare const RATE = 1.2; | ||
export declare const codes: Set<string>; | ||
export declare const retryBusy: (fn: (path: string) => Promise<any>) => (path: string, opt: RimrafOptions, backoff?: number, total?: number) => Promise<any>; | ||
export declare const retryBusy: (fn: (path: string) => Promise<any>) => (path: string, opt: RimrafAsyncOptions, backoff?: number, total?: number) => Promise<any>; | ||
export declare const retryBusySync: (fn: (path: string) => any) => (path: string, opt: RimrafOptions) => any; | ||
//# sourceMappingURL=retry-busy.d.ts.map |
@@ -1,3 +0,3 @@ | ||
export declare const rimrafManual: ((path: string, opt: import("./index.js").RimrafOptions) => Promise<any>) | ((path: string, opt: import("./index.js").RimrafOptions, state?: symbol) => Promise<void>); | ||
export declare const rimrafManualSync: (path: string, opt: import("./index.js").RimrafOptions, state?: symbol) => void; | ||
export declare const rimrafManual: (path: string, opt: import("./index.js").RimrafAsyncOptions, state?: symbol) => Promise<boolean>; | ||
export declare const rimrafManualSync: (path: string, opt: import("./index.js").RimrafSyncOptions, state?: symbol) => boolean; | ||
//# sourceMappingURL=rimraf-manual.d.ts.map |
@@ -1,4 +0,4 @@ | ||
import { RimrafOptions } from '.'; | ||
export declare const rimrafMoveRemove: (path: string, opt: RimrafOptions) => Promise<void>; | ||
export declare const rimrafMoveRemoveSync: (path: string, opt: RimrafOptions) => void; | ||
import { RimrafAsyncOptions, RimrafSyncOptions } from '.'; | ||
export declare const rimrafMoveRemove: (path: string, opt: RimrafAsyncOptions) => Promise<boolean>; | ||
export declare const rimrafMoveRemoveSync: (path: string, opt: RimrafSyncOptions) => boolean; | ||
//# sourceMappingURL=rimraf-move-remove.d.ts.map |
@@ -73,3 +73,3 @@ "use strict"; | ||
if (entries.code === 'ENOENT') { | ||
return; | ||
return true; | ||
} | ||
@@ -79,5 +79,12 @@ if (entries.code !== 'ENOTDIR') { | ||
} | ||
return await (0, ignore_enoent_js_1.ignoreENOENT)(tmpUnlink(path, opt.tmp, unlinkFixEPERM)); | ||
if (opt.filter && !(await opt.filter(path))) { | ||
return false; | ||
} | ||
await (0, ignore_enoent_js_1.ignoreENOENT)(tmpUnlink(path, opt.tmp, unlinkFixEPERM)); | ||
return true; | ||
} | ||
await Promise.all(entries.map(entry => (0, exports.rimrafMoveRemove)((0, path_1.resolve)(path, entry), opt))); | ||
const removedAll = (await Promise.all(entries.map(entry => (0, exports.rimrafMoveRemove)((0, path_1.resolve)(path, entry), opt)))).reduce((a, b) => a && b, true); | ||
if (!removedAll) { | ||
return false; | ||
} | ||
// we don't ever ACTUALLY try to unlink /, because that can never work | ||
@@ -87,5 +94,9 @@ // but when preserveRoot is false, we could be operating on it. | ||
if (opt.preserveRoot === false && path === (0, path_1.parse)(path).root) { | ||
return; | ||
return false; | ||
} | ||
return await (0, ignore_enoent_js_1.ignoreENOENT)(tmpUnlink(path, opt.tmp, rmdir)); | ||
if (opt.filter && !(await opt.filter(path))) { | ||
return false; | ||
} | ||
await (0, ignore_enoent_js_1.ignoreENOENT)(tmpUnlink(path, opt.tmp, rmdir)); | ||
return true; | ||
}; | ||
@@ -112,3 +123,3 @@ exports.rimrafMoveRemove = rimrafMoveRemove; | ||
if (entries.code === 'ENOENT') { | ||
return; | ||
return true; | ||
} | ||
@@ -118,11 +129,23 @@ if (entries.code !== 'ENOTDIR') { | ||
} | ||
return (0, ignore_enoent_js_1.ignoreENOENTSync)(() => tmpUnlinkSync(path, tmp, unlinkFixEPERMSync)); | ||
if (opt.filter && !opt.filter(path)) { | ||
return false; | ||
} | ||
(0, ignore_enoent_js_1.ignoreENOENTSync)(() => tmpUnlinkSync(path, tmp, unlinkFixEPERMSync)); | ||
return true; | ||
} | ||
let removedAll = true; | ||
for (const entry of entries) { | ||
(0, exports.rimrafMoveRemoveSync)((0, path_1.resolve)(path, entry), opt); | ||
removedAll = (0, exports.rimrafMoveRemoveSync)((0, path_1.resolve)(path, entry), opt) && removedAll; | ||
} | ||
if (!removedAll) { | ||
return false; | ||
} | ||
if (opt.preserveRoot === false && path === (0, path_1.parse)(path).root) { | ||
return; | ||
return false; | ||
} | ||
return (0, ignore_enoent_js_1.ignoreENOENTSync)(() => tmpUnlinkSync(path, tmp, fs_js_1.rmdirSync)); | ||
if (opt.filter && !opt.filter(path)) { | ||
return false; | ||
} | ||
(0, ignore_enoent_js_1.ignoreENOENTSync)(() => tmpUnlinkSync(path, tmp, fs_js_1.rmdirSync)); | ||
return true; | ||
}; | ||
@@ -129,0 +152,0 @@ exports.rimrafMoveRemoveSync = rimrafMoveRemoveSync; |
@@ -1,4 +0,4 @@ | ||
import { RimrafOptions } from '.'; | ||
export declare const rimrafNative: (path: string, opt: RimrafOptions) => Promise<void>; | ||
export declare const rimrafNativeSync: (path: string, opt: RimrafOptions) => void; | ||
import { RimrafAsyncOptions, RimrafSyncOptions } from '.'; | ||
export declare const rimrafNative: (path: string, opt: RimrafAsyncOptions) => Promise<boolean>; | ||
export declare const rimrafNativeSync: (path: string, opt: RimrafSyncOptions) => boolean; | ||
//# sourceMappingURL=rimraf-native.d.ts.map |
@@ -6,14 +6,20 @@ "use strict"; | ||
const { rm } = fs_js_1.promises; | ||
const rimrafNative = (path, opt) => rm(path, { | ||
...opt, | ||
force: true, | ||
recursive: true, | ||
}); | ||
const rimrafNative = async (path, opt) => { | ||
await rm(path, { | ||
...opt, | ||
force: true, | ||
recursive: true, | ||
}); | ||
return true; | ||
}; | ||
exports.rimrafNative = rimrafNative; | ||
const rimrafNativeSync = (path, opt) => (0, fs_js_1.rmSync)(path, { | ||
...opt, | ||
force: true, | ||
recursive: true, | ||
}); | ||
const rimrafNativeSync = (path, opt) => { | ||
(0, fs_js_1.rmSync)(path, { | ||
...opt, | ||
force: true, | ||
recursive: true, | ||
}); | ||
return true; | ||
}; | ||
exports.rimrafNativeSync = rimrafNativeSync; | ||
//# sourceMappingURL=rimraf-native.js.map |
@@ -1,4 +0,4 @@ | ||
import { RimrafOptions } from '.'; | ||
export declare const rimrafPosix: (path: string, opt: RimrafOptions) => Promise<any>; | ||
export declare const rimrafPosixSync: (path: string, opt: RimrafOptions) => any; | ||
import { RimrafAsyncOptions, RimrafSyncOptions } from '.'; | ||
export declare const rimrafPosix: (path: string, opt: RimrafAsyncOptions) => Promise<boolean>; | ||
export declare const rimrafPosixSync: (path: string, opt: RimrafSyncOptions) => boolean; | ||
//# sourceMappingURL=rimraf-posix.d.ts.map |
@@ -22,3 +22,3 @@ "use strict"; | ||
if (entries.code === 'ENOENT') { | ||
return; | ||
return true; | ||
} | ||
@@ -28,5 +28,12 @@ if (entries.code !== 'ENOTDIR') { | ||
} | ||
return (0, ignore_enoent_js_1.ignoreENOENT)(unlink(path)); | ||
if (opt.filter && !(await opt.filter(path))) { | ||
return false; | ||
} | ||
await (0, ignore_enoent_js_1.ignoreENOENT)(unlink(path)); | ||
return true; | ||
} | ||
await Promise.all(entries.map(entry => (0, exports.rimrafPosix)((0, path_1.resolve)(path, entry), opt))); | ||
const removedAll = (await Promise.all(entries.map(entry => (0, exports.rimrafPosix)((0, path_1.resolve)(path, entry), opt)))).reduce((a, b) => a && b, true); | ||
if (!removedAll) { | ||
return false; | ||
} | ||
// we don't ever ACTUALLY try to unlink /, because that can never work | ||
@@ -36,5 +43,9 @@ // but when preserveRoot is false, we could be operating on it. | ||
if (opt.preserveRoot === false && path === (0, path_1.parse)(path).root) { | ||
return; | ||
return false; | ||
} | ||
return (0, ignore_enoent_js_1.ignoreENOENT)(rmdir(path)); | ||
if (opt.filter && !(await opt.filter(path))) { | ||
return false; | ||
} | ||
await (0, ignore_enoent_js_1.ignoreENOENT)(rmdir(path)); | ||
return true; | ||
}; | ||
@@ -49,3 +60,3 @@ exports.rimrafPosix = rimrafPosix; | ||
if (entries.code === 'ENOENT') { | ||
return; | ||
return true; | ||
} | ||
@@ -55,13 +66,25 @@ if (entries.code !== 'ENOTDIR') { | ||
} | ||
return (0, ignore_enoent_js_1.ignoreENOENTSync)(() => (0, fs_js_1.unlinkSync)(path)); | ||
if (opt.filter && !opt.filter(path)) { | ||
return false; | ||
} | ||
(0, ignore_enoent_js_1.ignoreENOENTSync)(() => (0, fs_js_1.unlinkSync)(path)); | ||
return true; | ||
} | ||
let removedAll = true; | ||
for (const entry of entries) { | ||
(0, exports.rimrafPosixSync)((0, path_1.resolve)(path, entry), opt); | ||
removedAll = (0, exports.rimrafPosixSync)((0, path_1.resolve)(path, entry), opt) && removedAll; | ||
} | ||
if (opt.preserveRoot === false && path === (0, path_1.parse)(path).root) { | ||
return; | ||
return false; | ||
} | ||
return (0, ignore_enoent_js_1.ignoreENOENTSync)(() => (0, fs_js_1.rmdirSync)(path)); | ||
if (!removedAll) { | ||
return false; | ||
} | ||
if (opt.filter && !opt.filter(path)) { | ||
return false; | ||
} | ||
(0, ignore_enoent_js_1.ignoreENOENTSync)(() => (0, fs_js_1.rmdirSync)(path)); | ||
return true; | ||
}; | ||
exports.rimrafPosixSync = rimrafPosixSync; | ||
//# sourceMappingURL=rimraf-posix.js.map |
@@ -1,4 +0,4 @@ | ||
import { RimrafOptions } from '.'; | ||
export declare const rimrafWindows: (path: string, opt: RimrafOptions, state?: symbol) => Promise<void>; | ||
export declare const rimrafWindowsSync: (path: string, opt: RimrafOptions, state?: symbol) => void; | ||
import { RimrafAsyncOptions, RimrafSyncOptions } from '.'; | ||
export declare const rimrafWindows: (path: string, opt: RimrafAsyncOptions, state?: symbol) => Promise<boolean>; | ||
export declare const rimrafWindowsSync: (path: string, opt: RimrafSyncOptions, state?: symbol) => boolean; | ||
//# sourceMappingURL=rimraf-windows.d.ts.map |
@@ -31,8 +31,10 @@ "use strict"; | ||
/* c8 ignore stop */ | ||
// already filtered, remove from options so we don't call unnecessarily | ||
const { filter, ...options } = opt; | ||
try { | ||
await rimrafWindowsDir(path, opt); | ||
return await rimrafWindowsDir(path, options); | ||
} | ||
catch (er) { | ||
if (er?.code === 'ENOTEMPTY') { | ||
return await (0, rimraf_move_remove_js_1.rimrafMoveRemove)(path, opt); | ||
return await (0, rimraf_move_remove_js_1.rimrafMoveRemove)(path, options); | ||
} | ||
@@ -46,8 +48,11 @@ throw er; | ||
} | ||
// already filtered, remove from options so we don't call unnecessarily | ||
const { filter, ...options } = opt; | ||
try { | ||
rimrafWindowsDirSync(path, opt); | ||
return rimrafWindowsDirSync(path, options); | ||
} | ||
catch (er) { | ||
if (er?.code === 'ENOTEMPTY') { | ||
return (0, rimraf_move_remove_js_1.rimrafMoveRemoveSync)(path, opt); | ||
const fer = er; | ||
if (fer?.code === 'ENOTEMPTY') { | ||
return (0, rimraf_move_remove_js_1.rimrafMoveRemoveSync)(path, options); | ||
} | ||
@@ -71,3 +76,3 @@ throw er; | ||
if (entries.code === 'ENOENT') { | ||
return; | ||
return true; | ||
} | ||
@@ -77,6 +82,11 @@ if (entries.code !== 'ENOTDIR') { | ||
} | ||
if (opt.filter && !(await opt.filter(path))) { | ||
return false; | ||
} | ||
// is a file | ||
return (0, ignore_enoent_js_1.ignoreENOENT)(rimrafWindowsFile(path, opt)); | ||
await (0, ignore_enoent_js_1.ignoreENOENT)(rimrafWindowsFile(path, opt)); | ||
return true; | ||
} | ||
await Promise.all(entries.map(entry => (0, exports.rimrafWindows)((0, path_1.resolve)(path, entry), opt, state === START ? CHILD : state))); | ||
const s = state === START ? CHILD : state; | ||
const removedAll = (await Promise.all(entries.map(entry => (0, exports.rimrafWindows)((0, path_1.resolve)(path, entry), opt, s)))).reduce((a, b) => a && b, true); | ||
if (state === START) { | ||
@@ -87,6 +97,13 @@ return (0, exports.rimrafWindows)(path, opt, FINISH); | ||
if (opt.preserveRoot === false && path === (0, path_1.parse)(path).root) { | ||
return; | ||
return false; | ||
} | ||
return (0, ignore_enoent_js_1.ignoreENOENT)(rimrafWindowsDirMoveRemoveFallback(path, opt)); | ||
if (!removedAll) { | ||
return false; | ||
} | ||
if (opt.filter && !(await opt.filter(path))) { | ||
return false; | ||
} | ||
await (0, ignore_enoent_js_1.ignoreENOENT)(rimrafWindowsDirMoveRemoveFallback(path, opt)); | ||
} | ||
return true; | ||
}; | ||
@@ -101,3 +118,3 @@ exports.rimrafWindows = rimrafWindows; | ||
if (entries.code === 'ENOENT') { | ||
return; | ||
return true; | ||
} | ||
@@ -107,8 +124,13 @@ if (entries.code !== 'ENOTDIR') { | ||
} | ||
if (opt.filter && !opt.filter(path)) { | ||
return false; | ||
} | ||
// is a file | ||
return (0, ignore_enoent_js_1.ignoreENOENTSync)(() => rimrafWindowsFileSync(path, opt)); | ||
(0, ignore_enoent_js_1.ignoreENOENTSync)(() => rimrafWindowsFileSync(path, opt)); | ||
return true; | ||
} | ||
let removedAll = true; | ||
for (const entry of entries) { | ||
const s = state === START ? CHILD : state; | ||
(0, exports.rimrafWindowsSync)((0, path_1.resolve)(path, entry), opt, s); | ||
removedAll = (0, exports.rimrafWindowsSync)((0, path_1.resolve)(path, entry), opt, s) && removedAll; | ||
} | ||
@@ -120,10 +142,17 @@ if (state === START) { | ||
if (opt.preserveRoot === false && path === (0, path_1.parse)(path).root) { | ||
return; | ||
return false; | ||
} | ||
return (0, ignore_enoent_js_1.ignoreENOENTSync)(() => { | ||
if (!removedAll) { | ||
return false; | ||
} | ||
if (opt.filter && !opt.filter(path)) { | ||
return false; | ||
} | ||
(0, ignore_enoent_js_1.ignoreENOENTSync)(() => { | ||
rimrafWindowsDirMoveRemoveFallbackSync(path, opt); | ||
}); | ||
} | ||
return true; | ||
}; | ||
exports.rimrafWindowsSync = rimrafWindowsSync; | ||
//# sourceMappingURL=rimraf-windows.js.map |
@@ -1,4 +0,4 @@ | ||
import { RimrafOptions } from './index.js'; | ||
export declare const useNative: (opt?: RimrafOptions) => boolean; | ||
import { RimrafAsyncOptions, RimrafOptions } from './index.js'; | ||
export declare const useNative: (opt?: RimrafAsyncOptions) => boolean; | ||
export declare const useNativeSync: (opt?: RimrafOptions) => boolean; | ||
//# sourceMappingURL=use-native.d.ts.map |
@@ -13,4 +13,8 @@ "use strict"; | ||
const platform_js_1 = __importDefault(require("./platform.js")); | ||
exports.useNative = !hasNative || platform_js_1.default === 'win32' ? () => false : opt => !opt?.signal; | ||
exports.useNativeSync = !hasNative || platform_js_1.default === 'win32' ? () => false : opt => !opt?.signal; | ||
exports.useNative = !hasNative || platform_js_1.default === 'win32' | ||
? () => false | ||
: opt => !opt?.signal && !opt?.filter; | ||
exports.useNativeSync = !hasNative || platform_js_1.default === 'win32' | ||
? () => false | ||
: opt => !opt?.signal && !opt?.filter; | ||
//# sourceMappingURL=use-native.js.map |
import { GlobOptions } from 'glob'; | ||
export interface RimrafOptions { | ||
export interface RimrafAsyncOptions { | ||
preserveRoot?: boolean; | ||
@@ -11,55 +11,60 @@ tmp?: string; | ||
glob?: boolean | GlobOptions; | ||
filter?: ((path: string) => boolean) | ((path: string) => Promise<boolean>); | ||
} | ||
export interface RimrafSyncOptions extends RimrafAsyncOptions { | ||
filter?: (path: string) => boolean; | ||
} | ||
export type RimrafOptions = RimrafSyncOptions | RimrafAsyncOptions; | ||
export declare const isRimrafOptions: (o: any) => o is RimrafOptions; | ||
export declare const assertRimrafOptions: (o: any) => void; | ||
export declare const nativeSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const native: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const nativeSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
export declare const native: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
export declare const manualSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const manual: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const manualSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
export declare const manual: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
export declare const windowsSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const windows: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const windowsSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
export declare const windows: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
export declare const posixSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const posix: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const posixSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
export declare const posix: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
export declare const moveRemoveSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const moveRemove: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const moveRemoveSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
export declare const moveRemove: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
export declare const rimrafSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const rimraf: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
rimraf: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
export declare const rimrafSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
export declare const sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
export declare const rimraf: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
rimraf: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
rimrafSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
manual: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
rimrafSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
manual: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
manualSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
native: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
manualSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
native: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
nativeSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
posix: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
nativeSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
posix: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
posixSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
windows: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
posixSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
windows: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
windowsSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
moveRemove: ((path: string | string[], opt?: RimrafOptions) => Promise<void>) & { | ||
sync: (path: string | string[], opt?: RimrafOptions) => void; | ||
windowsSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
moveRemove: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise<boolean>) & { | ||
sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
moveRemoveSync: (path: string | string[], opt?: RimrafOptions) => void; | ||
moveRemoveSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean; | ||
}; | ||
export default rimraf; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import optArg from './opt-arg.js'; | ||
import { optArg, optArgSync } from './opt-arg.js'; | ||
import pathArg from './path-arg.js'; | ||
@@ -13,3 +13,4 @@ import { glob, globSync } from 'glob'; | ||
typeOrUndef(o.maxBackoff, 'number') && | ||
(typeOrUndef(o.glob, 'boolean') || (o.glob && typeof o.glob === 'object')); | ||
(typeOrUndef(o.glob, 'boolean') || (o.glob && typeof o.glob === 'object')) && | ||
typeOrUndef(o.filter, 'function'); | ||
export const assertRimrafOptions = (o) => { | ||
@@ -31,14 +32,22 @@ if (!isRimrafOptions(o)) { | ||
} | ||
await (Array.isArray(path) | ||
? Promise.all(path.map(p => fn(pathArg(p, options), options))) | ||
: fn(pathArg(path, options), options)); | ||
if (Array.isArray(path)) { | ||
return !!(await Promise.all(path.map(p => fn(pathArg(p, options), options)))).reduce((a, b) => a && b, true); | ||
} | ||
else { | ||
return !!(await fn(pathArg(path, options), options)); | ||
} | ||
}; | ||
const wrapSync = (fn) => (path, opt) => { | ||
const options = optArg(opt); | ||
const options = optArgSync(opt); | ||
if (options.glob) { | ||
path = globSync(path, options.glob); | ||
} | ||
return Array.isArray(path) | ||
? path.forEach(p => fn(pathArg(p, options), options)) | ||
: fn(pathArg(path, options), options); | ||
if (Array.isArray(path)) { | ||
return !!path | ||
.map(p => fn(pathArg(p, options), options)) | ||
.reduce((a, b) => a && b, true); | ||
} | ||
else { | ||
return !!fn(pathArg(path, options), options); | ||
} | ||
}; | ||
@@ -45,0 +54,0 @@ export const nativeSync = wrapSync(rimrafNativeSync); |
import { GlobOptions } from 'glob'; | ||
import { RimrafOptions } from './index.js'; | ||
declare const _default: (opt?: RimrafOptions) => RimrafOptions & { | ||
glob?: (GlobOptions & { | ||
import { RimrafAsyncOptions, RimrafSyncOptions } from './index.js'; | ||
export declare const optArg: (opt?: RimrafAsyncOptions) => (RimrafAsyncOptions & { | ||
glob: GlobOptions & { | ||
withFileTypes: false; | ||
}) | undefined; | ||
}; | ||
export default _default; | ||
}; | ||
}) | (RimrafAsyncOptions & { | ||
glob: undefined; | ||
}); | ||
export declare const optArgSync: (opt?: RimrafSyncOptions) => (RimrafSyncOptions & { | ||
glob: GlobOptions & { | ||
withFileTypes: false; | ||
}; | ||
}) | (RimrafSyncOptions & { | ||
glob: undefined; | ||
}); | ||
//# sourceMappingURL=opt-arg.d.ts.map |
@@ -1,7 +0,8 @@ | ||
import { assertRimrafOptions } from './index.js'; | ||
export default (opt = {}) => { | ||
import { assertRimrafOptions, } from './index.js'; | ||
const optArgT = (opt) => { | ||
assertRimrafOptions(opt); | ||
const { glob, ...options } = opt; | ||
if (!glob) | ||
if (!glob) { | ||
return options; | ||
} | ||
const globOpt = glob === true | ||
@@ -28,2 +29,4 @@ ? opt.signal | ||
}; | ||
export const optArg = (opt = {}) => optArgT(opt); | ||
export const optArgSync = (opt = {}) => optArgT(opt); | ||
//# sourceMappingURL=opt-arg.js.map |
{ | ||
"version": "4.1.4", | ||
"version": "4.2.0", | ||
"type": "module" | ||
} |
@@ -1,4 +0,4 @@ | ||
import { RimrafOptions } from './index.js'; | ||
declare const pathArg: (path: string, opt?: RimrafOptions) => string; | ||
import { RimrafAsyncOptions } from './index.js'; | ||
declare const pathArg: (path: string, opt?: RimrafAsyncOptions) => string; | ||
export default pathArg; | ||
//# sourceMappingURL=path-arg.d.ts.map |
@@ -0,4 +1,4 @@ | ||
import { parse, resolve } from 'path'; | ||
import { inspect } from 'util'; | ||
import platform from './platform.js'; | ||
import { resolve, parse } from 'path'; | ||
import { inspect } from 'util'; | ||
const pathArg = (path, opt = {}) => { | ||
@@ -5,0 +5,0 @@ const type = typeof path; |
@@ -1,2 +0,2 @@ | ||
import { RimrafOptions } from '.'; | ||
import { RimrafAsyncOptions, RimrafOptions } from '.'; | ||
export declare const MAXBACKOFF = 200; | ||
@@ -6,4 +6,4 @@ export declare const RATE = 1.2; | ||
export declare const codes: Set<string>; | ||
export declare const retryBusy: (fn: (path: string) => Promise<any>) => (path: string, opt: RimrafOptions, backoff?: number, total?: number) => Promise<any>; | ||
export declare const retryBusy: (fn: (path: string) => Promise<any>) => (path: string, opt: RimrafAsyncOptions, backoff?: number, total?: number) => Promise<any>; | ||
export declare const retryBusySync: (fn: (path: string) => any) => (path: string, opt: RimrafOptions) => any; | ||
//# sourceMappingURL=retry-busy.d.ts.map |
@@ -1,3 +0,3 @@ | ||
export declare const rimrafManual: ((path: string, opt: import("./index.js").RimrafOptions) => Promise<any>) | ((path: string, opt: import("./index.js").RimrafOptions, state?: symbol) => Promise<void>); | ||
export declare const rimrafManualSync: (path: string, opt: import("./index.js").RimrafOptions, state?: symbol) => void; | ||
export declare const rimrafManual: (path: string, opt: import("./index.js").RimrafAsyncOptions, state?: symbol) => Promise<boolean>; | ||
export declare const rimrafManualSync: (path: string, opt: import("./index.js").RimrafSyncOptions, state?: symbol) => boolean; | ||
//# sourceMappingURL=rimraf-manual.d.ts.map |
@@ -1,4 +0,4 @@ | ||
import { RimrafOptions } from '.'; | ||
export declare const rimrafMoveRemove: (path: string, opt: RimrafOptions) => Promise<void>; | ||
export declare const rimrafMoveRemoveSync: (path: string, opt: RimrafOptions) => void; | ||
import { RimrafAsyncOptions, RimrafSyncOptions } from '.'; | ||
export declare const rimrafMoveRemove: (path: string, opt: RimrafAsyncOptions) => Promise<boolean>; | ||
export declare const rimrafMoveRemoveSync: (path: string, opt: RimrafSyncOptions) => boolean; | ||
//# sourceMappingURL=rimraf-move-remove.d.ts.map |
@@ -70,3 +70,3 @@ // https://youtu.be/uhRWMGBjlO8?t=537 | ||
if (entries.code === 'ENOENT') { | ||
return; | ||
return true; | ||
} | ||
@@ -76,5 +76,12 @@ if (entries.code !== 'ENOTDIR') { | ||
} | ||
return await ignoreENOENT(tmpUnlink(path, opt.tmp, unlinkFixEPERM)); | ||
if (opt.filter && !(await opt.filter(path))) { | ||
return false; | ||
} | ||
await ignoreENOENT(tmpUnlink(path, opt.tmp, unlinkFixEPERM)); | ||
return true; | ||
} | ||
await Promise.all(entries.map(entry => rimrafMoveRemove(resolve(path, entry), opt))); | ||
const removedAll = (await Promise.all(entries.map(entry => rimrafMoveRemove(resolve(path, entry), opt)))).reduce((a, b) => a && b, true); | ||
if (!removedAll) { | ||
return false; | ||
} | ||
// we don't ever ACTUALLY try to unlink /, because that can never work | ||
@@ -84,5 +91,9 @@ // but when preserveRoot is false, we could be operating on it. | ||
if (opt.preserveRoot === false && path === parse(path).root) { | ||
return; | ||
return false; | ||
} | ||
return await ignoreENOENT(tmpUnlink(path, opt.tmp, rmdir)); | ||
if (opt.filter && !(await opt.filter(path))) { | ||
return false; | ||
} | ||
await ignoreENOENT(tmpUnlink(path, opt.tmp, rmdir)); | ||
return true; | ||
}; | ||
@@ -108,3 +119,3 @@ const tmpUnlink = async (path, tmp, rm) => { | ||
if (entries.code === 'ENOENT') { | ||
return; | ||
return true; | ||
} | ||
@@ -114,11 +125,23 @@ if (entries.code !== 'ENOTDIR') { | ||
} | ||
return ignoreENOENTSync(() => tmpUnlinkSync(path, tmp, unlinkFixEPERMSync)); | ||
if (opt.filter && !opt.filter(path)) { | ||
return false; | ||
} | ||
ignoreENOENTSync(() => tmpUnlinkSync(path, tmp, unlinkFixEPERMSync)); | ||
return true; | ||
} | ||
let removedAll = true; | ||
for (const entry of entries) { | ||
rimrafMoveRemoveSync(resolve(path, entry), opt); | ||
removedAll = rimrafMoveRemoveSync(resolve(path, entry), opt) && removedAll; | ||
} | ||
if (!removedAll) { | ||
return false; | ||
} | ||
if (opt.preserveRoot === false && path === parse(path).root) { | ||
return; | ||
return false; | ||
} | ||
return ignoreENOENTSync(() => tmpUnlinkSync(path, tmp, rmdirSync)); | ||
if (opt.filter && !opt.filter(path)) { | ||
return false; | ||
} | ||
ignoreENOENTSync(() => tmpUnlinkSync(path, tmp, rmdirSync)); | ||
return true; | ||
}; | ||
@@ -125,0 +148,0 @@ const tmpUnlinkSync = (path, tmp, rmSync) => { |
@@ -1,4 +0,4 @@ | ||
import { RimrafOptions } from '.'; | ||
export declare const rimrafNative: (path: string, opt: RimrafOptions) => Promise<void>; | ||
export declare const rimrafNativeSync: (path: string, opt: RimrafOptions) => void; | ||
import { RimrafAsyncOptions, RimrafSyncOptions } from '.'; | ||
export declare const rimrafNative: (path: string, opt: RimrafAsyncOptions) => Promise<boolean>; | ||
export declare const rimrafNativeSync: (path: string, opt: RimrafSyncOptions) => boolean; | ||
//# sourceMappingURL=rimraf-native.d.ts.map |
import { promises, rmSync } from './fs.js'; | ||
const { rm } = promises; | ||
export const rimrafNative = (path, opt) => rm(path, { | ||
...opt, | ||
force: true, | ||
recursive: true, | ||
}); | ||
export const rimrafNativeSync = (path, opt) => rmSync(path, { | ||
...opt, | ||
force: true, | ||
recursive: true, | ||
}); | ||
export const rimrafNative = async (path, opt) => { | ||
await rm(path, { | ||
...opt, | ||
force: true, | ||
recursive: true, | ||
}); | ||
return true; | ||
}; | ||
export const rimrafNativeSync = (path, opt) => { | ||
rmSync(path, { | ||
...opt, | ||
force: true, | ||
recursive: true, | ||
}); | ||
return true; | ||
}; | ||
//# sourceMappingURL=rimraf-native.js.map |
@@ -1,4 +0,4 @@ | ||
import { RimrafOptions } from '.'; | ||
export declare const rimrafPosix: (path: string, opt: RimrafOptions) => Promise<any>; | ||
export declare const rimrafPosixSync: (path: string, opt: RimrafOptions) => any; | ||
import { RimrafAsyncOptions, RimrafSyncOptions } from '.'; | ||
export declare const rimrafPosix: (path: string, opt: RimrafAsyncOptions) => Promise<boolean>; | ||
export declare const rimrafPosixSync: (path: string, opt: RimrafSyncOptions) => boolean; | ||
//# sourceMappingURL=rimraf-posix.d.ts.map |
@@ -19,3 +19,3 @@ // the simple recursive removal, where unlink and rmdir are atomic | ||
if (entries.code === 'ENOENT') { | ||
return; | ||
return true; | ||
} | ||
@@ -25,5 +25,12 @@ if (entries.code !== 'ENOTDIR') { | ||
} | ||
return ignoreENOENT(unlink(path)); | ||
if (opt.filter && !(await opt.filter(path))) { | ||
return false; | ||
} | ||
await ignoreENOENT(unlink(path)); | ||
return true; | ||
} | ||
await Promise.all(entries.map(entry => rimrafPosix(resolve(path, entry), opt))); | ||
const removedAll = (await Promise.all(entries.map(entry => rimrafPosix(resolve(path, entry), opt)))).reduce((a, b) => a && b, true); | ||
if (!removedAll) { | ||
return false; | ||
} | ||
// we don't ever ACTUALLY try to unlink /, because that can never work | ||
@@ -33,5 +40,9 @@ // but when preserveRoot is false, we could be operating on it. | ||
if (opt.preserveRoot === false && path === parse(path).root) { | ||
return; | ||
return false; | ||
} | ||
return ignoreENOENT(rmdir(path)); | ||
if (opt.filter && !(await opt.filter(path))) { | ||
return false; | ||
} | ||
await ignoreENOENT(rmdir(path)); | ||
return true; | ||
}; | ||
@@ -45,3 +56,3 @@ export const rimrafPosixSync = (path, opt) => { | ||
if (entries.code === 'ENOENT') { | ||
return; | ||
return true; | ||
} | ||
@@ -51,12 +62,24 @@ if (entries.code !== 'ENOTDIR') { | ||
} | ||
return ignoreENOENTSync(() => unlinkSync(path)); | ||
if (opt.filter && !opt.filter(path)) { | ||
return false; | ||
} | ||
ignoreENOENTSync(() => unlinkSync(path)); | ||
return true; | ||
} | ||
let removedAll = true; | ||
for (const entry of entries) { | ||
rimrafPosixSync(resolve(path, entry), opt); | ||
removedAll = rimrafPosixSync(resolve(path, entry), opt) && removedAll; | ||
} | ||
if (opt.preserveRoot === false && path === parse(path).root) { | ||
return; | ||
return false; | ||
} | ||
return ignoreENOENTSync(() => rmdirSync(path)); | ||
if (!removedAll) { | ||
return false; | ||
} | ||
if (opt.filter && !opt.filter(path)) { | ||
return false; | ||
} | ||
ignoreENOENTSync(() => rmdirSync(path)); | ||
return true; | ||
}; | ||
//# sourceMappingURL=rimraf-posix.js.map |
@@ -1,4 +0,4 @@ | ||
import { RimrafOptions } from '.'; | ||
export declare const rimrafWindows: (path: string, opt: RimrafOptions, state?: symbol) => Promise<void>; | ||
export declare const rimrafWindowsSync: (path: string, opt: RimrafOptions, state?: symbol) => void; | ||
import { RimrafAsyncOptions, RimrafSyncOptions } from '.'; | ||
export declare const rimrafWindows: (path: string, opt: RimrafAsyncOptions, state?: symbol) => Promise<boolean>; | ||
export declare const rimrafWindowsSync: (path: string, opt: RimrafSyncOptions, state?: symbol) => boolean; | ||
//# sourceMappingURL=rimraf-windows.d.ts.map |
@@ -28,8 +28,10 @@ // This is the same as rimrafPosix, with the following changes: | ||
/* c8 ignore stop */ | ||
// already filtered, remove from options so we don't call unnecessarily | ||
const { filter, ...options } = opt; | ||
try { | ||
await rimrafWindowsDir(path, opt); | ||
return await rimrafWindowsDir(path, options); | ||
} | ||
catch (er) { | ||
if (er?.code === 'ENOTEMPTY') { | ||
return await rimrafMoveRemove(path, opt); | ||
return await rimrafMoveRemove(path, options); | ||
} | ||
@@ -43,8 +45,11 @@ throw er; | ||
} | ||
// already filtered, remove from options so we don't call unnecessarily | ||
const { filter, ...options } = opt; | ||
try { | ||
rimrafWindowsDirSync(path, opt); | ||
return rimrafWindowsDirSync(path, options); | ||
} | ||
catch (er) { | ||
if (er?.code === 'ENOTEMPTY') { | ||
return rimrafMoveRemoveSync(path, opt); | ||
const fer = er; | ||
if (fer?.code === 'ENOTEMPTY') { | ||
return rimrafMoveRemoveSync(path, options); | ||
} | ||
@@ -68,3 +73,3 @@ throw er; | ||
if (entries.code === 'ENOENT') { | ||
return; | ||
return true; | ||
} | ||
@@ -74,6 +79,11 @@ if (entries.code !== 'ENOTDIR') { | ||
} | ||
if (opt.filter && !(await opt.filter(path))) { | ||
return false; | ||
} | ||
// is a file | ||
return ignoreENOENT(rimrafWindowsFile(path, opt)); | ||
await ignoreENOENT(rimrafWindowsFile(path, opt)); | ||
return true; | ||
} | ||
await Promise.all(entries.map(entry => rimrafWindows(resolve(path, entry), opt, state === START ? CHILD : state))); | ||
const s = state === START ? CHILD : state; | ||
const removedAll = (await Promise.all(entries.map(entry => rimrafWindows(resolve(path, entry), opt, s)))).reduce((a, b) => a && b, true); | ||
if (state === START) { | ||
@@ -84,6 +94,13 @@ return rimrafWindows(path, opt, FINISH); | ||
if (opt.preserveRoot === false && path === parse(path).root) { | ||
return; | ||
return false; | ||
} | ||
return ignoreENOENT(rimrafWindowsDirMoveRemoveFallback(path, opt)); | ||
if (!removedAll) { | ||
return false; | ||
} | ||
if (opt.filter && !(await opt.filter(path))) { | ||
return false; | ||
} | ||
await ignoreENOENT(rimrafWindowsDirMoveRemoveFallback(path, opt)); | ||
} | ||
return true; | ||
}; | ||
@@ -97,3 +114,3 @@ export const rimrafWindowsSync = (path, opt, state = START) => { | ||
if (entries.code === 'ENOENT') { | ||
return; | ||
return true; | ||
} | ||
@@ -103,8 +120,13 @@ if (entries.code !== 'ENOTDIR') { | ||
} | ||
if (opt.filter && !opt.filter(path)) { | ||
return false; | ||
} | ||
// is a file | ||
return ignoreENOENTSync(() => rimrafWindowsFileSync(path, opt)); | ||
ignoreENOENTSync(() => rimrafWindowsFileSync(path, opt)); | ||
return true; | ||
} | ||
let removedAll = true; | ||
for (const entry of entries) { | ||
const s = state === START ? CHILD : state; | ||
rimrafWindowsSync(resolve(path, entry), opt, s); | ||
removedAll = rimrafWindowsSync(resolve(path, entry), opt, s) && removedAll; | ||
} | ||
@@ -116,9 +138,16 @@ if (state === START) { | ||
if (opt.preserveRoot === false && path === parse(path).root) { | ||
return; | ||
return false; | ||
} | ||
return ignoreENOENTSync(() => { | ||
if (!removedAll) { | ||
return false; | ||
} | ||
if (opt.filter && !opt.filter(path)) { | ||
return false; | ||
} | ||
ignoreENOENTSync(() => { | ||
rimrafWindowsDirMoveRemoveFallbackSync(path, opt); | ||
}); | ||
} | ||
return true; | ||
}; | ||
//# sourceMappingURL=rimraf-windows.js.map |
@@ -1,4 +0,4 @@ | ||
import { RimrafOptions } from './index.js'; | ||
export declare const useNative: (opt?: RimrafOptions) => boolean; | ||
import { RimrafAsyncOptions, RimrafOptions } from './index.js'; | ||
export declare const useNative: (opt?: RimrafAsyncOptions) => boolean; | ||
export declare const useNativeSync: (opt?: RimrafOptions) => boolean; | ||
//# sourceMappingURL=use-native.d.ts.map |
@@ -7,4 +7,8 @@ const version = process.env.__TESTING_RIMRAF_NODE_VERSION__ || process.version; | ||
import platform from './platform.js'; | ||
export const useNative = !hasNative || platform === 'win32' ? () => false : opt => !opt?.signal; | ||
export const useNativeSync = !hasNative || platform === 'win32' ? () => false : opt => !opt?.signal; | ||
export const useNative = !hasNative || platform === 'win32' | ||
? () => false | ||
: opt => !opt?.signal && !opt?.filter; | ||
export const useNativeSync = !hasNative || platform === 'win32' | ||
? () => false | ||
: opt => !opt?.signal && !opt?.filter; | ||
//# sourceMappingURL=use-native.js.map |
{ | ||
"name": "rimraf", | ||
"version": "4.2.0", | ||
"version": "4.3.0", | ||
"main": "./dist/cjs/src/index-cjs.js", | ||
@@ -60,3 +60,3 @@ "module": "./dist/mjs/index.js", | ||
"prettier": "^2.8.2", | ||
"tap": "^16.3.3", | ||
"tap": "^16.3.4", | ||
"ts-node": "^10.9.1", | ||
@@ -63,0 +63,0 @@ "typedoc": "^0.23.21", |
@@ -8,3 +8,4 @@ The [UNIX command](<http://en.wikipedia.org/wiki/Rm_(Unix)>) `rm -rf` for node. | ||
- The function returns a `Promise` instead of taking a callback. | ||
- Built-in glob support removed. | ||
- Globbing requires the `--glob` option to be set. (Removed in | ||
4.0 and 4.1, opt-in support added in 4.2.) | ||
- Functions take arrays of paths, as well as a single path. | ||
@@ -18,2 +19,3 @@ - Native implementation used by default when available, except on | ||
affordances are not necessary there. | ||
- As of 4.3, return/resolve value is boolean instead of undefined | ||
@@ -36,2 +38,8 @@ ## API | ||
All removal functions return a boolean indicating that all | ||
entries were successfully removed. | ||
The only case in which this will not return `true` is if | ||
something was omitted from the removal via a `filter` option. | ||
### `rimraf(f, [opts]) -> Promise` | ||
@@ -69,6 +77,25 @@ | ||
removal. This is useful when removing large folder structures, | ||
if you'd like to limit the amount of time spent. Using a | ||
`signal` option prevents the use of Node's built-in `fs.rm` | ||
because that implementation does not support abort signals. | ||
if you'd like to limit the amount of time spent. | ||
Using a `signal` option prevents the use of Node's built-in | ||
`fs.rm` because that implementation does not support abort | ||
signals. | ||
- `filter` Method that receives a path string as an argument, and | ||
returns a boolean indicating whether that path should be | ||
deleted. With async rimraf methods, this may return a Promise | ||
that resolves to a boolean. (Since Promises are truthy, | ||
returning a Promise from a sync filter is the same as just not | ||
filtering anything.) | ||
If a filter method is provided, it will _only_ remove entries | ||
if the filter returns (or resolves to) a truthy value. Omitting | ||
a directory will still allow its children to be removed, unless | ||
they are also filtered out, but any parents of a filtered entry | ||
will not be removed, since the directory would not be empty in | ||
that case. | ||
Using a filter method prevents the use of Node's built-in | ||
`fs.rm` because that implementation does not support filtering. | ||
Any other options are provided to the native Node.js `fs.rm` implementation | ||
@@ -148,3 +175,3 @@ when that is used. | ||
``` | ||
rimraf version 4.2.0 | ||
rimraf version 4.3.0 | ||
@@ -155,21 +182,29 @@ Usage: rimraf <path> [<path> ...] | ||
Options: | ||
-- Treat all subsequent arguments as paths | ||
-h --help Display this usage info | ||
--preserve-root Do not remove '/' recursively (default) | ||
--no-preserve-root Do not treat '/' specially | ||
-G --no-glob Treat arguments as literal paths, not globs (default) | ||
-g --glob Treat arguments as glob patterns | ||
-- Treat all subsequent arguments as paths | ||
-h --help Display this usage info | ||
--preserve-root Do not remove '/' recursively (default) | ||
--no-preserve-root Do not treat '/' specially | ||
-G --no-glob Treat arguments as literal paths, not globs (default) | ||
-g --glob Treat arguments as glob patterns | ||
-v --verbose Be verbose when deleting files, showing them as | ||
they are removed. Not compatible with --impl=native | ||
-V --no-verbose Be silent when deleting files, showing nothing as | ||
they are removed (default) | ||
-i --interactive Ask for confirmation before deleting anything | ||
Not compatible with --impl=native | ||
-I --no-interactive Do not ask for confirmation before deleting | ||
--impl=<type> Specify the implementation to use. | ||
rimraf: choose the best option | ||
native: the built-in implementation in Node.js | ||
manual: the platform-specific JS implementation | ||
posix: the Posix JS implementation | ||
windows: the Windows JS implementation | ||
move-remove: a slower Windows JS fallback implementation | ||
--impl=<type> Specify the implementation to use: | ||
rimraf: choose the best option (default) | ||
native: the built-in implementation in Node.js | ||
manual: the platform-specific JS implementation | ||
posix: the Posix JS implementation | ||
windows: the Windows JS implementation (falls back to | ||
move-remove on ENOTEMPTY) | ||
move-remove: a slow reliable Windows fallback | ||
Implementation-specific options: | ||
--tmp=<path> Folder to hold temp files for 'move-remove' implementation | ||
--max-retries=<n> maxRetries for the 'native' and 'windows' implementations | ||
--retry-delay=<n> retryDelay for the 'native' implementation, default 100 | ||
--tmp=<path> Temp file folder for 'move-remove' implementation | ||
--max-retries=<n> maxRetries for 'native' and 'windows' implementations | ||
--retry-delay=<n> retryDelay for 'native' implementation, default 100 | ||
--backoff=<n> Exponential backoff factor for retries (default: 1.2) | ||
@@ -176,0 +211,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
191746
2267
211