Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jsenv/filesystem

Package Overview
Dependencies
Maintainers
2
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jsenv/filesystem - npm Package Compare versions

Comparing version 4.9.2 to 4.9.3

4

package.json
{
"name": "@jsenv/filesystem",
"version": "4.9.2",
"version": "4.9.3",
"license": "MIT",

@@ -37,4 +37,4 @@ "repository": {

"@jsenv/abort": "4.3.0",
"@jsenv/utils": "2.1.1"
"@jsenv/utils": "2.1.2"
}
}

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

import { Abort } from "@jsenv/abort";
import {

@@ -21,3 +20,2 @@ ensurePathnameTrailingSlash,

{
signal = new AbortController().signal,
allowUseless = false,

@@ -31,47 +29,37 @@ recursive = false,

const sourceUrl = assertAndNormalizeFileUrl(source);
const removeOperation = Abort.startOperation();
removeOperation.addAbortSignal(signal);
try {
removeOperation.throwIfAborted();
const sourceStats = readEntryStatSync(sourceUrl, {
nullIfNotFound: true,
followLink: false,
});
if (!sourceStats) {
if (allowUseless) {
return;
}
throw new Error(`nothing to remove at ${urlToFileSystemPath(sourceUrl)}`);
const sourceStats = readEntryStatSync(sourceUrl, {
nullIfNotFound: true,
followLink: false,
});
if (!sourceStats) {
if (allowUseless) {
return;
}
throw new Error(`nothing to remove at ${urlToFileSystemPath(sourceUrl)}`);
}
// https://nodejs.org/dist/latest-v13.x/docs/api/fs.html#fs_class_fs_stats
// FIFO and socket are ignored, not sure what they are exactly and what to do with them
// other libraries ignore them, let's do the same.
if (
sourceStats.isFile() ||
sourceStats.isSymbolicLink() ||
sourceStats.isCharacterDevice() ||
sourceStats.isBlockDevice()
) {
removeNonDirectory(
sourceUrl.endsWith("/") ? sourceUrl.slice(0, -1) : sourceUrl,
{
maxRetries,
retryDelay,
},
);
} else if (sourceStats.isDirectory()) {
const directoryUrl = ensurePathnameTrailingSlash(sourceUrl);
removeDirectorySync(directoryUrl, {
signal: removeOperation.signal,
recursive,
// https://nodejs.org/dist/latest-v13.x/docs/api/fs.html#fs_class_fs_stats
// FIFO and socket are ignored, not sure what they are exactly and what to do with them
// other libraries ignore them, let's do the same.
if (
sourceStats.isFile() ||
sourceStats.isSymbolicLink() ||
sourceStats.isCharacterDevice() ||
sourceStats.isBlockDevice()
) {
removeNonDirectory(
sourceUrl.endsWith("/") ? sourceUrl.slice(0, -1) : sourceUrl,
{
maxRetries,
retryDelay,
onlyContent,
});
}
} finally {
removeOperation.end();
},
);
} else if (sourceStats.isDirectory()) {
const directoryUrl = ensurePathnameTrailingSlash(sourceUrl);
removeDirectorySync(directoryUrl, {
recursive,
maxRetries,
retryDelay,
onlyContent,
});
}

@@ -111,9 +99,5 @@ };

rootDirectoryUrl,
{ signal, maxRetries, retryDelay, recursive, onlyContent },
{ maxRetries, retryDelay, recursive, onlyContent },
) => {
const removeDirectoryOperation = Abort.startOperation();
removeDirectoryOperation.addAbortSignal(signal);
const visit = (sourceUrl) => {
removeDirectoryOperation.throwIfAborted();
const sourceStats = readEntryStatSync(sourceUrl, {

@@ -152,3 +136,2 @@ nullIfNotFound: true,

: {};
removeDirectoryOperation.throwIfAborted();
removeDirectorySyncNaive(directoryPath, {

@@ -191,3 +174,2 @@ ...optionsFromRecursive,

const removeDirectoryContent = (directoryUrl) => {
removeDirectoryOperation.throwIfAborted();
const entryNames = readdirSync(new URL(directoryUrl));

@@ -208,10 +190,6 @@ for (const entryName of entryNames) {

try {
if (onlyContent) {
removeDirectoryContent(rootDirectoryUrl);
} else {
visitDirectory(rootDirectoryUrl);
}
} finally {
removeDirectoryOperation.end();
if (onlyContent) {
removeDirectoryContent(rootDirectoryUrl);
} else {
visitDirectory(rootDirectoryUrl);
}

@@ -218,0 +196,0 @@ };

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