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

@codesandbox/nodebox

Package Overview
Dependencies
Maintainers
4
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codesandbox/nodebox - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

1

build/index.d.ts

@@ -5,1 +5,2 @@ export * from './messages';

export * from './logger';
export type { IFileStats } from './modules/fs';

@@ -867,9 +867,44 @@ "use strict";

});
return response ? response.data : void 0;
if (!response) {
throw new Error("File not found");
}
return response.data;
}
async writeFile(path, content, encoding) {
await this.channel.send("fs/writeFile", { path, content, encoding }).catch((error) => {
async writeFile(path, content, options) {
let encoding = void 0;
let recursive = false;
if (typeof options === "object") {
encoding = options.encoding;
recursive = !!options.recursive;
} else if (typeof options === "string") {
encoding = options;
}
await this.channel.send("fs/writeFile", { path, content, encoding, recursive }).catch((error) => {
throw new Error((0, import_outvariant2.format)('Failed to write file at path "%s"', path), { cause: error });
});
}
async readdir(path) {
const response = await this.channel.send("fs/readdir", { path }).catch((error) => {
throw new Error((0, import_outvariant2.format)('Failed to read directory at path "%s"', path), { cause: error });
});
if (!response) {
throw new Error("Directory not found");
}
return response.data;
}
async mkdir(path, options) {
const recursive = !!options?.recursive;
await this.channel.send("fs/mkdir", { path, recursive }).catch((error) => {
throw new Error((0, import_outvariant2.format)('Failed to make directory at path "%s"', path), { cause: error });
});
}
async stat(path) {
const response = await this.channel.send("fs/stat", { path }).catch((error) => {
throw new Error((0, import_outvariant2.format)('Failed to stat file at path "%s"', path), { cause: error });
});
if (!response) {
throw new Error("File not found");
}
return response.data;
}
async watch(includes, excludes, listener) {

@@ -876,0 +911,0 @@ const watcherId = (0, import_cuid2.default)();

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

export declare type FileWatchEvent = Omit<FSWatchEvent, 'watcherId'>;
export interface IFileStats {
type: 'dir' | 'file' | 'link';
size: number;
ino: number;
atimeMs: number;
mtimeMs: number;
ctimeMs: number;
blocks: number;
mode: number;
}
export interface FileSystemEvents {

@@ -21,3 +31,3 @@ 'fs/init': {

}, {
data?: Uint8Array;
data: Uint8Array;
}] | [{

@@ -27,3 +37,3 @@ path: string;

}, {
data?: Uint8Array;
data: Uint8Array;
}] | [{

@@ -33,3 +43,3 @@ path: string;

}, {
data?: string | FileContent;
data: string | FileContent;
}];

@@ -40,3 +50,24 @@ 'fs/writeFile': {

encoding?: BufferEncoding;
recursive?: boolean;
};
'fs/readdir': [
{
path: string;
},
{
data: string[];
}
];
'fs/stat': [
{
path: string;
},
{
data: IFileStats;
}
];
'fs/mkdir': {
path: string;
recursive?: boolean;
};
'fs/watch': {

@@ -51,2 +82,6 @@ watcherId: string;

}
declare type WriteFileOptions = BufferEncoding | {
encoding?: BufferEncoding;
recursive?: boolean;
};
export declare class FileSystemApi {

@@ -70,3 +105,8 @@ private readonly channel;

writeFile(path: string, content: Uint8Array): Promise<void>;
writeFile(path: string, content: string, encoding: BufferEncoding): Promise<void>;
writeFile(path: string, content: string, options: WriteFileOptions): Promise<void>;
readdir(path: string): Promise<string[]>;
mkdir(path: string, options?: {
recursive?: boolean;
}): Promise<void>;
stat(path: string): Promise<IFileStats>;
/**

@@ -73,0 +113,0 @@ * Subscribe to changes at the given file or directory.

2

package.json
{
"name": "@codesandbox/nodebox",
"version": "0.1.1",
"version": "0.1.2",
"description": "Public API of Nodebox",

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

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