Socket
Socket
Sign inDemoInstall

rimraf

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rimraf - npm Package Compare versions

Comparing version 4.1.4 to 4.2.0

5

dist/cjs/package.json
{
"name": "rimraf",
"version": "4.1.4",
"version": "4.2.0",
"main": "./dist/cjs/src/index-cjs.js",

@@ -80,3 +80,6 @@ "module": "./dist/mjs/index.js",

"node": ">=14"
},
"dependencies": {
"glob": "^9.2.0"
}
}

12

dist/cjs/src/bin.js

@@ -21,4 +21,6 @@ #!/usr/bin/env node

--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
--impl=<type> Specify the implementationt to use.
--impl=<type> Specify the implementation to use.
rimraf: choose the best option

@@ -63,2 +65,10 @@ native: the built-in implementation in Node.js

}
else if (arg === '-g' || arg === '--glob') {
opt.glob = true;
continue;
}
else if (arg === '-G' || arg === '--no-glob') {
opt.glob = false;
continue;
}
else if (arg === '--preserve-root') {

@@ -65,0 +75,0 @@ opt.preserveRoot = true;

@@ -0,1 +1,2 @@

import { GlobOptions } from 'glob';
export interface RimrafOptions {

@@ -8,2 +9,4 @@ preserveRoot?: boolean;

maxBackoff?: number;
signal?: AbortSignal;
glob?: boolean | GlobOptions;
}

@@ -10,0 +13,0 @@ export declare const isRimrafOptions: (o: any) => o is RimrafOptions;

@@ -9,2 +9,3 @@ "use strict";

const path_arg_js_1 = __importDefault(require("./path-arg.js"));
const glob_1 = require("glob");
const typeOrUndef = (val, t) => typeof val === 'undefined' || typeof val === t;

@@ -18,3 +19,4 @@ const isRimrafOptions = (o) => !!o &&

typeOrUndef(o.backoff, 'number') &&
typeOrUndef(o.maxBackoff, 'number');
typeOrUndef(o.maxBackoff, 'number') &&
(typeOrUndef(o.glob, 'boolean') || (o.glob && typeof o.glob === 'object'));
exports.isRimrafOptions = isRimrafOptions;

@@ -35,2 +37,5 @@ const assertRimrafOptions = (o) => {

const options = (0, opt_arg_js_1.default)(opt);
if (options.glob) {
path = await (0, glob_1.glob)(path, options.glob);
}
await (Array.isArray(path)

@@ -42,2 +47,5 @@ ? Promise.all(path.map(p => fn((0, path_arg_js_1.default)(p, options), options)))

const options = (0, opt_arg_js_1.default)(opt);
if (options.glob) {
path = (0, glob_1.globSync)(path, options.glob);
}
return Array.isArray(path)

@@ -59,5 +67,5 @@ ? path.forEach(p => fn((0, path_arg_js_1.default)(p, options), options))

});
exports.rimrafSync = wrapSync((path, opt) => (0, use_native_js_1.useNativeSync)() ? (0, rimraf_native_js_1.rimrafNativeSync)(path, opt) : (0, rimraf_manual_js_1.rimrafManualSync)(path, opt));
exports.rimrafSync = wrapSync((path, opt) => (0, use_native_js_1.useNativeSync)(opt) ? (0, rimraf_native_js_1.rimrafNativeSync)(path, opt) : (0, rimraf_manual_js_1.rimrafManualSync)(path, opt));
exports.sync = exports.rimrafSync;
exports.rimraf = Object.assign(wrap((path, opt) => (0, use_native_js_1.useNative)() ? (0, rimraf_native_js_1.rimrafNative)(path, opt) : (0, rimraf_manual_js_1.rimrafManual)(path, opt)), {
exports.rimraf = Object.assign(wrap((path, opt) => (0, use_native_js_1.useNative)(opt) ? (0, rimraf_native_js_1.rimrafNative)(path, opt) : (0, rimraf_manual_js_1.rimrafManual)(path, opt)), {
// this weirdness because it's easier than explicitly declaring

@@ -64,0 +72,0 @@ rimraf: exports.manual,

@@ -0,4 +1,9 @@

import { GlobOptions } from 'glob';
import { RimrafOptions } from './index.js';
declare const _default: (opt?: RimrafOptions) => RimrafOptions;
declare const _default: (opt?: RimrafOptions) => RimrafOptions & {
glob?: (GlobOptions & {
withFileTypes: false;
}) | undefined;
};
export default _default;
//# sourceMappingURL=opt-arg.d.ts.map

@@ -6,4 +6,26 @@ "use strict";

(0, index_js_1.assertRimrafOptions)(opt);
return opt;
const { glob, ...options } = opt;
if (!glob)
return options;
const globOpt = glob === true
? opt.signal
? { signal: opt.signal }
: {}
: opt.signal
? {
signal: opt.signal,
...glob,
}
: glob;
return {
...options,
glob: {
...globOpt,
// always get absolute paths from glob, to ensure
// that we are referencing the correct thing.
absolute: true,
withFileTypes: false,
},
};
};
//# sourceMappingURL=opt-arg.js.map

@@ -61,2 +61,5 @@ "use strict";

const rimrafMoveRemove = async (path, opt) => {
if (opt?.signal?.aborted) {
throw opt.signal.reason;
}
if (!opt.tmp) {

@@ -94,2 +97,5 @@ return (0, exports.rimrafMoveRemove)(path, { ...opt, tmp: await (0, default_tmp_js_1.defaultTmp)(path) });

const rimrafMoveRemoveSync = (path, opt) => {
if (opt?.signal?.aborted) {
throw opt.signal.reason;
}
if (!opt.tmp) {

@@ -96,0 +102,0 @@ return (0, exports.rimrafMoveRemoveSync)(path, { ...opt, tmp: (0, default_tmp_js_1.defaultTmpSync)(path) });

@@ -16,2 +16,5 @@ "use strict";

const rimrafPosix = async (path, opt) => {
if (opt?.signal?.aborted) {
throw opt.signal.reason;
}
const entries = await (0, readdir_or_error_js_1.readdirOrError)(path);

@@ -38,2 +41,5 @@ if (!Array.isArray(entries)) {

const rimrafPosixSync = (path, opt) => {
if (opt?.signal?.aborted) {
throw opt.signal.reason;
}
const entries = (0, readdir_or_error_js_1.readdirOrErrorSync)(path);

@@ -40,0 +46,0 @@ if (!Array.isArray(entries)) {

@@ -26,2 +26,7 @@ "use strict";

const rimrafWindowsDirMoveRemoveFallback = async (path, opt) => {
/* c8 ignore start */
if (opt?.signal?.aborted) {
throw opt.signal.reason;
}
/* c8 ignore stop */
try {

@@ -38,2 +43,5 @@ await rimrafWindowsDir(path, opt);

const rimrafWindowsDirMoveRemoveFallbackSync = (path, opt) => {
if (opt?.signal?.aborted) {
throw opt.signal.reason;
}
try {

@@ -54,2 +62,5 @@ rimrafWindowsDirSync(path, opt);

const rimrafWindows = async (path, opt, state = START) => {
if (opt?.signal?.aborted) {
throw opt.signal.reason;
}
if (!states.has(state)) {

@@ -56,0 +67,0 @@ throw new TypeError('invalid third argument passed to rimraf');

@@ -1,3 +0,4 @@

export declare const useNative: () => boolean;
export declare const useNativeSync: () => boolean;
import { RimrafOptions } from './index.js';
export declare const useNative: (opt?: RimrafOptions) => boolean;
export declare const useNativeSync: (opt?: RimrafOptions) => boolean;
//# sourceMappingURL=use-native.d.ts.map

@@ -13,4 +13,4 @@ "use strict";

const platform_js_1 = __importDefault(require("./platform.js"));
exports.useNative = !hasNative || platform_js_1.default === 'win32' ? () => false : () => true;
exports.useNativeSync = !hasNative || platform_js_1.default === 'win32' ? () => false : () => true;
exports.useNative = !hasNative || platform_js_1.default === 'win32' ? () => false : opt => !opt?.signal;
exports.useNativeSync = !hasNative || platform_js_1.default === 'win32' ? () => false : opt => !opt?.signal;
//# sourceMappingURL=use-native.js.map

@@ -0,1 +1,2 @@

import { GlobOptions } from 'glob';
export interface RimrafOptions {

@@ -8,2 +9,4 @@ preserveRoot?: boolean;

maxBackoff?: number;
signal?: AbortSignal;
glob?: boolean | GlobOptions;
}

@@ -10,0 +13,0 @@ export declare const isRimrafOptions: (o: any) => o is RimrafOptions;

import optArg from './opt-arg.js';
import pathArg from './path-arg.js';
import { glob, globSync } from 'glob';
const typeOrUndef = (val, t) => typeof val === 'undefined' || typeof val === t;

@@ -11,3 +12,4 @@ export const isRimrafOptions = (o) => !!o &&

typeOrUndef(o.backoff, 'number') &&
typeOrUndef(o.maxBackoff, 'number');
typeOrUndef(o.maxBackoff, 'number') &&
(typeOrUndef(o.glob, 'boolean') || (o.glob && typeof o.glob === 'object'));
export const assertRimrafOptions = (o) => {

@@ -26,2 +28,5 @@ if (!isRimrafOptions(o)) {

const options = optArg(opt);
if (options.glob) {
path = await glob(path, options.glob);
}
await (Array.isArray(path)

@@ -33,2 +38,5 @@ ? Promise.all(path.map(p => fn(pathArg(p, options), options)))

const options = optArg(opt);
if (options.glob) {
path = globSync(path, options.glob);
}
return Array.isArray(path)

@@ -50,5 +58,5 @@ ? path.forEach(p => fn(pathArg(p, options), options))

});
export const rimrafSync = wrapSync((path, opt) => useNativeSync() ? rimrafNativeSync(path, opt) : rimrafManualSync(path, opt));
export const rimrafSync = wrapSync((path, opt) => useNativeSync(opt) ? rimrafNativeSync(path, opt) : rimrafManualSync(path, opt));
export const sync = rimrafSync;
export const rimraf = Object.assign(wrap((path, opt) => useNative() ? rimrafNative(path, opt) : rimrafManual(path, opt)), {
export const rimraf = Object.assign(wrap((path, opt) => useNative(opt) ? rimrafNative(path, opt) : rimrafManual(path, opt)), {
// this weirdness because it's easier than explicitly declaring

@@ -55,0 +63,0 @@ rimraf: manual,

@@ -0,4 +1,9 @@

import { GlobOptions } from 'glob';
import { RimrafOptions } from './index.js';
declare const _default: (opt?: RimrafOptions) => RimrafOptions;
declare const _default: (opt?: RimrafOptions) => RimrafOptions & {
glob?: (GlobOptions & {
withFileTypes: false;
}) | undefined;
};
export default _default;
//# sourceMappingURL=opt-arg.d.ts.map
import { assertRimrafOptions } from './index.js';
export default (opt = {}) => {
assertRimrafOptions(opt);
return opt;
const { glob, ...options } = opt;
if (!glob)
return options;
const globOpt = glob === true
? opt.signal
? { signal: opt.signal }
: {}
: opt.signal
? {
signal: opt.signal,
...glob,
}
: glob;
return {
...options,
glob: {
...globOpt,
// always get absolute paths from glob, to ensure
// that we are referencing the correct thing.
absolute: true,
withFileTypes: false,
},
};
};
//# sourceMappingURL=opt-arg.js.map
{
"version": "4.1.4",
"type": "module"
}

@@ -58,2 +58,5 @@ // https://youtu.be/uhRWMGBjlO8?t=537

export const rimrafMoveRemove = async (path, opt) => {
if (opt?.signal?.aborted) {
throw opt.signal.reason;
}
if (!opt.tmp) {

@@ -90,2 +93,5 @@ return rimrafMoveRemove(path, { ...opt, tmp: await defaultTmp(path) });

export const rimrafMoveRemoveSync = (path, opt) => {
if (opt?.signal?.aborted) {
throw opt.signal.reason;
}
if (!opt.tmp) {

@@ -92,0 +98,0 @@ return rimrafMoveRemoveSync(path, { ...opt, tmp: defaultTmpSync(path) });

@@ -13,2 +13,5 @@ // the simple recursive removal, where unlink and rmdir are atomic

export const rimrafPosix = async (path, opt) => {
if (opt?.signal?.aborted) {
throw opt.signal.reason;
}
const entries = await readdirOrError(path);

@@ -34,2 +37,5 @@ if (!Array.isArray(entries)) {

export const rimrafPosixSync = (path, opt) => {
if (opt?.signal?.aborted) {
throw opt.signal.reason;
}
const entries = readdirOrErrorSync(path);

@@ -36,0 +42,0 @@ if (!Array.isArray(entries)) {

@@ -23,2 +23,7 @@ // This is the same as rimrafPosix, with the following changes:

const rimrafWindowsDirMoveRemoveFallback = async (path, opt) => {
/* c8 ignore start */
if (opt?.signal?.aborted) {
throw opt.signal.reason;
}
/* c8 ignore stop */
try {

@@ -35,2 +40,5 @@ await rimrafWindowsDir(path, opt);

const rimrafWindowsDirMoveRemoveFallbackSync = (path, opt) => {
if (opt?.signal?.aborted) {
throw opt.signal.reason;
}
try {

@@ -51,2 +59,5 @@ rimrafWindowsDirSync(path, opt);

export const rimrafWindows = async (path, opt, state = START) => {
if (opt?.signal?.aborted) {
throw opt.signal.reason;
}
if (!states.has(state)) {

@@ -53,0 +64,0 @@ throw new TypeError('invalid third argument passed to rimraf');

@@ -1,3 +0,4 @@

export declare const useNative: () => boolean;
export declare const useNativeSync: () => boolean;
import { RimrafOptions } from './index.js';
export declare const useNative: (opt?: RimrafOptions) => boolean;
export declare const useNativeSync: (opt?: RimrafOptions) => boolean;
//# sourceMappingURL=use-native.d.ts.map

@@ -7,4 +7,4 @@ const version = process.env.__TESTING_RIMRAF_NODE_VERSION__ || process.version;

import platform from './platform.js';
export const useNative = !hasNative || platform === 'win32' ? () => false : () => true;
export const useNativeSync = !hasNative || platform === 'win32' ? () => false : () => true;
export const useNative = !hasNative || platform === 'win32' ? () => false : opt => !opt?.signal;
export const useNativeSync = !hasNative || platform === 'win32' ? () => false : opt => !opt?.signal;
//# sourceMappingURL=use-native.js.map
{
"name": "rimraf",
"version": "4.1.4",
"version": "4.2.0",
"main": "./dist/cjs/src/index-cjs.js",

@@ -80,3 +80,6 @@ "module": "./dist/mjs/index.js",

"node": ">=14"
},
"dependencies": {
"glob": "^9.2.0"
}
}

@@ -64,2 +64,7 @@ The [UNIX command](<http://en.wikipedia.org/wiki/Rm_(Unix)>) `rm -rf` for node.

linear backoff. Default `100`.
- `signal` Pass in an AbortSignal to cancel the directory
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.

@@ -140,3 +145,3 @@ Any other options are provided to the native Node.js `fs.rm` implementation

```
rimraf version 4.0.4
rimraf version 4.2.0

@@ -151,4 +156,6 @@ Usage: rimraf <path> [<path> ...]

--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
--impl=<type> Specify the implementationt to use.
--impl=<type> Specify the implementation to use.
rimraf: choose the best option

@@ -155,0 +162,0 @@ native: the built-in implementation in Node.js

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc