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

@file-services/node

Package Overview
Dependencies
Maintainers
4
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@file-services/node - npm Package Compare versions

Comparing version 5.7.1 to 6.0.0

6

dist/index.js
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

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

const caseSensitive = !fs_1.default.existsSync(__filename.toUpperCase());
const fsPromisesExists = (0, util_1.promisify)(fs_1.default.exists);
function createNodeFs(options) {

@@ -22,2 +23,3 @@ return (0, utils_1.createFileSystem)(createBaseNodeFs(options));

function createBaseNodeFs(options) {
var _a, _b;
return {

@@ -32,5 +34,7 @@ ...path_1.default,

lstatSync: needsStatPolyfill ? lstatSync : fs_1.default.lstatSync,
rmSync: (_a = fs_1.default.rmSync) !== null && _a !== void 0 ? _a : rmSync,
promises: {
...fs_1.default.promises,
exists: (0, util_1.promisify)(fs_1.default.exists),
rm: (_b = fs_1.default.promises.rm) !== null && _b !== void 0 ? _b : rm,
exists: fsPromisesExists,
},

@@ -70,2 +74,34 @@ };

}
function rmSync(path, { force, recursive } = {}) {
if (recursive) {
// when recursive is specified, we want to be able to delete both files and directories
// we use rmdirSync in that case, as we know it exists and handles both cases in recursive mode
if (!force) {
// when force isn't specified, we want this function to throw if the path doesn't exist
// since recursive rmdirSync never throws, we call statSync that throws ENOENT if path doesn't exist
fs_1.default.statSync(path);
}
fs_1.default.rmdirSync(path, { recursive });
}
else if (!force || fs_1.default.existsSync(path)) {
// we check force or existance of path to match error throwing behavior
fs_1.default.unlinkSync(path);
}
}
async function rm(path, { force, recursive } = {}) {
if (recursive) {
// when recursive is specified, we want to be able to delete both files and directories
// we use rmdir in that case, as we know it exists and handles both cases in recursive mode
if (!force) {
// when force isn't specified, we want this function to reject if the path doesn't exist
// since recursive rmdir never rejects, we call stat that rejects ENOENT if path doesn't exist
await fs_1.default.promises.stat(path);
}
await fs_1.default.promises.rmdir(path, { recursive });
}
else if (!force || (await fsPromisesExists(path))) {
// we check force or existance of path to match error rejection behavior
await fs_1.default.promises.unlink(path);
}
}
//# sourceMappingURL=node-fs.js.map

6

package.json
{
"name": "@file-services/node",
"description": "Node.js file system implementation.",
"version": "5.7.1",
"version": "6.0.0",
"main": "dist/index.js",

@@ -11,4 +11,4 @@ "scripts": {

"dependencies": {
"@file-services/types": "^5.7.1",
"@file-services/utils": "^5.7.1"
"@file-services/types": "^6.0.0",
"@file-services/utils": "^6.0.0"
},

@@ -15,0 +15,0 @@ "files": [

@@ -12,2 +12,3 @@ import fs from 'fs';

IFileSystemStats,
RmOptions,
StatSyncOptions,

@@ -20,2 +21,3 @@ } from '@file-services/types';

const caseSensitive = !fs.existsSync(__filename.toUpperCase());
const fsPromisesExists = promisify(fs.exists);

@@ -40,5 +42,7 @@ export interface ICreateNodeFsOptions {

lstatSync: needsStatPolyfill ? lstatSync : fs.lstatSync,
rmSync: fs.rmSync ?? rmSync, // node 12 fallback
promises: {
...fs.promises,
exists: promisify(fs.exists),
rm: fs.promises.rm ?? rm, // node 12 fallback
exists: fsPromisesExists,
},

@@ -52,3 +56,3 @@ };

try {
return fs.statSync(path, options as fs.StatOptions);
return fs.statSync(path, options);
} catch (e) {

@@ -68,3 +72,3 @@ const throwIfNoEntry = options?.throwIfNoEntry ?? true;

try {
return fs.lstatSync(path, options as fs.StatOptions);
return fs.lstatSync(path, options);
} catch (e) {

@@ -79,1 +83,33 @@ const throwIfNoEntry = options?.throwIfNoEntry ?? true;

}
function rmSync(path: string, { force, recursive }: RmOptions = {}): void {
if (recursive) {
// when recursive is specified, we want to be able to delete both files and directories
// we use rmdirSync in that case, as we know it exists and handles both cases in recursive mode
if (!force) {
// when force isn't specified, we want this function to throw if the path doesn't exist
// since recursive rmdirSync never throws, we call statSync that throws ENOENT if path doesn't exist
fs.statSync(path);
}
fs.rmdirSync(path, { recursive });
} else if (!force || fs.existsSync(path)) {
// we check force or existance of path to match error throwing behavior
fs.unlinkSync(path);
}
}
async function rm(path: string, { force, recursive }: RmOptions = {}): Promise<void> {
if (recursive) {
// when recursive is specified, we want to be able to delete both files and directories
// we use rmdir in that case, as we know it exists and handles both cases in recursive mode
if (!force) {
// when force isn't specified, we want this function to reject if the path doesn't exist
// since recursive rmdir never rejects, we call stat that rejects ENOENT if path doesn't exist
await fs.promises.stat(path);
}
await fs.promises.rmdir(path, { recursive });
} else if (!force || (await fsPromisesExists(path))) {
// we check force or existance of path to match error rejection behavior
await fs.promises.unlink(path);
}
}

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