New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

filesystem-sandbox

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filesystem-sandbox - npm Package Compare versions

Comparing version 1.18.0 to 1.19.0

1

dist/index.d.ts

@@ -18,2 +18,3 @@ /// <reference types="node" />

writeFile(at: string, contents: string | Buffer | string[]): Promise<string>;
appendFile(at: string, contents: string | Buffer | string[]): Promise<string>;
mkdir(name: string): Promise<string>;

@@ -20,0 +21,0 @@ private resolveRelativePath;

34

dist/index.js

@@ -36,3 +36,3 @@ "use strict";

const rimraf_1 = require("rimraf");
const { writeFile, readFile, stat } = fs_1.promises;
const { writeFile, readFile, stat, appendFile } = fs_1.promises;
async function isFolder(p) {

@@ -71,2 +71,12 @@ try {

const sandboxes = [];
async function writeData(fullPath, contents, writeFunction) {
const options = contents instanceof Buffer
? undefined
: { encoding: "utf8" };
if (Array.isArray(contents)) {
contents = contents.join("\n");
}
await writeFunction(fullPath, contents, options);
return fullPath;
}
class Sandbox {

@@ -111,18 +121,18 @@ constructor(at) {

async writeFile(at, contents) {
const providedAt = at;
at = this.resolveRelativePath(at);
const fullPath = this.fullPathFor(at), options = contents instanceof Buffer
? undefined
: { encoding: "utf8" };
if (Array.isArray(contents)) {
contents = contents.join("\n");
try {
await this.mkdir(path_1.default.dirname(at));
return await writeData(this.fullPathFor(at), contents, writeFile);
}
await this.mkdir(path_1.default.dirname(at));
catch (e) {
throw new Error(`Unable to write file at ${at}: ${e.message || e}`);
}
}
async appendFile(at, contents) {
try {
await writeFile(fullPath, contents, options);
await this.mkdir(path_1.default.dirname(at));
return await writeData(this.fullPathFor(at), contents, appendFile);
}
catch (e) {
throw new Error(`Unable to write file at: ${providedAt}: ${e.message || e}`);
throw new Error(`Unable to append to file at ${at}: ${e.message || e}`);
}
return fullPath;
}

@@ -129,0 +139,0 @@ async mkdir(name) {

{
"name": "filesystem-sandbox",
"version": "1.18.0",
"version": "1.19.0",
"description": "JavaScript module to provide filesystem sandboxes for testing",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -0,0 +0,0 @@ filesystem-sandbox

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