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

@zenfs/core

Package Overview
Dependencies
Maintainers
0
Versions
170
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zenfs/core - npm Package Compare versions

Comparing version 1.8.6 to 1.8.7

18

dist/vfs/promises.js

@@ -944,2 +944,20 @@ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {

return cache.paths.getAsync(ctx_path);
/* Try to resolve it directly. If this works,
that means we don't need to perform any resolution for parent directories. */
try {
const { fs, path: resolvedPath } = resolveMount(path, this);
// Stat it to make sure it exists
const stats = await fs.stat(resolvedPath);
let real = path.toString();
if (stats.isSymbolicLink()) {
const target = resolve(dirname(resolvedPath), (await readlink.call(this, resolvedPath, options)).toString());
real = cache.paths.get(((this === null || this === void 0 ? void 0 : this.root) || '') + target) || (await realpath.call(this, target));
cache.paths.set(ctx_path, real);
}
cache.paths.set(path.toString(), real);
return real;
}
catch {
// Go the long way
}
const { base, dir } = parse(path);

@@ -946,0 +964,0 @@ const realDir = dir == '/' ? '/' : await (cache.paths.getAsync(((this === null || this === void 0 ? void 0 : this.root) || '') + dir) || realpath.call(this, dir));

@@ -636,2 +636,20 @@ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {

return cache.paths.get(ctx_path);
/* Try to resolve it directly. If this works,
that means we don't need to perform any resolution for parent directories. */
try {
const { fs, path: resolvedPath } = resolveMount(path, this);
// Stat it to make sure it exists
const stats = fs.statSync(resolvedPath);
let real = path;
if (stats.isSymbolicLink()) {
const target = resolve(dirname(resolvedPath), readlinkSync.call(this, resolvedPath, options).toString());
real = cache.paths.get(((this === null || this === void 0 ? void 0 : this.root) || '') + target) || realpathSync.call(this, target);
cache.paths.set(ctx_path, real);
}
cache.paths.set(path, real);
return real;
}
catch {
// Go the long way
}
const { base, dir } = parse(path);

@@ -638,0 +656,0 @@ const realDir = dir == '/' ? '/' : cache.paths.get(((this === null || this === void 0 ? void 0 : this.root) || '') + dir) || realpathSync.call(this, dir);

2

package.json
{
"name": "@zenfs/core",
"version": "1.8.6",
"version": "1.8.7",
"description": "A filesystem, anywhere",

@@ -5,0 +5,0 @@ "funding": {

import { suite, test } from 'node:test';
import assert from 'node:assert';
import assert from 'node:assert/strict';
import { bindContext } from '../../dist/context.js';

@@ -18,4 +18,4 @@ import * as fs from '../../dist/vfs/index.js';

await ctx.promises.symlink('/example.txt', '/link');
assert.strictEqual(await ctx.promises.readlink('link', 'utf8'), '/example.txt');
assert.strictEqual(await fs.promises.readlink('/ctx/link'), '/example.txt');
assert.equal(await ctx.promises.readlink('link', 'utf8'), '/example.txt');
assert.equal(await fs.promises.readlink('/ctx/link'), '/example.txt');
assert.deepEqual(await ctx.promises.readFile('/link', 'utf-8'), await fs.promises.readFile('/ctx/example.txt', 'utf-8'));

@@ -29,8 +29,8 @@

// Correct/normal
assert.strictEqual(ctx.realpathSync('/'), '/');
assert.strictEqual(ctx.realpathSync('example.txt'), '/example.txt');
assert.strictEqual(ctx.realpathSync('../link'), '/example.txt');
assert.strictEqual(await ctx.promises.realpath('/../link'), '/example.txt');
assert.equal(ctx.realpathSync('/'), '/');
assert.equal(ctx.realpathSync('example.txt'), '/example.txt');
assert.equal(ctx.realpathSync('../link'), '/example.txt');
assert.equal(await ctx.promises.realpath('/../link'), '/example.txt');
assert.strictEqual(fs.realpathSync('/ctx/link'), '/example.txt');
assert.equal(fs.realpathSync('/ctx/link'), '/example.txt');
});

@@ -54,6 +54,6 @@

await ctx.promises.writeFile('/xpto.txt', 'in real root');
assert.strictEqual(lastFile!, 'xpto.txt');
assert.equal(lastFile!, 'xpto.txt');
await ctx.promises.unlink('/xpto.txt');
assert.strictEqual(lastFile, 'xpto.txt');
assert.equal(lastFile, 'xpto.txt');
});
});
import { suite, test } from 'node:test';
import assert from 'node:assert';
import assert from 'node:assert/strict';
import { configure } from '../../dist/config.js';

@@ -4,0 +4,0 @@ import * as fs from '../../dist/vfs/index.js';

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -3,0 +3,0 @@ import { constants, type FileHandle, open } from '../../dist/vfs/promises.js';

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -15,4 +15,4 @@ import { configure } from '../../dist/config.js';

assert.deepStrictEqual(fs.readdirSync('/'), ['nested']);
assert.deepStrictEqual(fs.readdirSync('/nested'), ['dir']);
assert.deepEqual(fs.readdirSync('/'), ['nested']);
assert.deepEqual(fs.readdirSync('/nested'), ['dir']);

@@ -19,0 +19,0 @@ // cleanup

@@ -6,3 +6,3 @@ import { wait } from 'utilium';

import { suite, test } from 'node:test';
import assert from 'node:assert';
import assert from 'node:assert/strict';

@@ -61,4 +61,4 @@ suite('LockFS mutex', () => {

await Promise.all([foo(), foo(), foo()]);
assert.strictEqual(x, 4);
assert.equal(x, 4);
});
});

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -3,0 +3,0 @@ import { basename, dirname, extname, join, normalize, resolve } from '../../dist/vfs/path.js';

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -3,0 +3,0 @@ import { fs } from '../common.js';

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

import assert, { rejects } from 'node:assert';
import assert, { rejects } from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -71,3 +71,3 @@ import { fs, type Dirent } from '../common.js';

const dirent3 = await dir.read();
assert.strictEqual(dirent3, null);
assert.equal(dirent3, null);

@@ -89,3 +89,3 @@ await dir.close();

const dirent3 = dir.readSync();
assert.strictEqual(dirent3, null);
assert.equal(dirent3, null);

@@ -115,3 +115,3 @@ dir.closeSync();

assert.strictEqual(dirents.length, 2);
assert.equal(dirents.length, 2);
assert(dirents[0] instanceof fs.Dirent);

@@ -118,0 +118,0 @@ assert(testFiles.includes(dirents[0].name));

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -35,3 +35,3 @@ import { ErrnoError } from '../../dist/error.js';

assert(error instanceof ErrnoError);
assert.strictEqual(error.code, 'ENOENT');
assert.equal(error.code, 'ENOENT');
}

@@ -70,3 +70,3 @@ assert(!(await fs.promises.exists('/nested/dir')));

assert(error instanceof ErrnoError);
assert.strictEqual(error.code, 'EACCES');
assert.equal(error.code, 'EACCES');
}

@@ -83,3 +83,3 @@ });

assert(error instanceof ErrnoError);
assert.strictEqual(error.code, 'ENOTEMPTY');
assert.equal(error.code, 'ENOTEMPTY');
}

@@ -96,3 +96,3 @@ });

wasThrown = true;
assert.strictEqual(error.code, 'ENOTDIR');
assert.equal(error.code, 'ENOTDIR');
}

@@ -107,3 +107,3 @@ assert(wasThrown);

assert(error instanceof ErrnoError);
assert.strictEqual(error.code, 'ENOTDIR');
assert.equal(error.code, 'ENOTDIR');
}

@@ -120,3 +120,3 @@ });

wasThrown = true;
assert.strictEqual(error.code, 'ENOENT');
assert.equal(error.code, 'ENOENT');
}

@@ -131,3 +131,3 @@ assert(wasThrown);

assert(error instanceof ErrnoError);
assert.strictEqual(error.code, 'ENOENT');
assert.equal(error.code, 'ENOENT');
}

@@ -134,0 +134,0 @@ });

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import test, { suite } from 'node:test';

@@ -3,0 +3,0 @@ import type { ErrnoError } from '../../dist/error.js';

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -3,0 +3,0 @@ import { fs } from '../common.js';

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -23,3 +23,3 @@ import { join } from '../../dist/vfs/path.js';

const destination = await fs.promises.readlink(symlink);
assert.strictEqual(destination, target);
assert.equal(destination, target);
});

@@ -47,3 +47,3 @@

const linkContent = await fs.promises.readFile(hardlink, 'utf8');
assert.strictEqual(targetContent, linkContent);
assert.equal(targetContent, linkContent);
});

@@ -57,4 +57,4 @@

const linkContent = await fs.promises.readFile(link, 'utf8');
assert.strictEqual(targetContent, linkContent);
assert.equal(targetContent, linkContent);
});
});

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -15,3 +15,3 @@ import { ErrnoError } from '../../dist/error.js';

assert(error instanceof ErrnoError);
assert.strictEqual(error?.code, 'ENOENT');
assert.equal(error?.code, 'ENOENT');
caughtException = true;

@@ -27,3 +27,3 @@ }

assert(error instanceof ErrnoError);
assert.strictEqual(error?.code, 'ENOENT');
assert.equal(error?.code, 'ENOENT');
}

@@ -30,0 +30,0 @@ });

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -53,3 +53,3 @@ import { credentials } from '../../dist/credentials.js';

assert(error instanceof ErrnoError);
assert.strictEqual(error.code, 'EACCES');
assert.equal(error.code, 'EACCES');
});

@@ -56,0 +56,0 @@ if (!stats) {

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -30,3 +30,3 @@ import { fs } from '../common.js';

const buff = await fs.promises.readFile('elipses.txt');
assert.strictEqual((buff[1] << 8) | buff[0], 32994);
assert.equal((buff[1] << 8) | buff[0], 32994);
});

@@ -36,3 +36,3 @@

const buff = fs.readFileSync('elipses.txt');
assert.strictEqual((buff[1] << 8) | buff[0], 32994);
assert.equal((buff[1] << 8) | buff[0], 32994);
});

@@ -49,4 +49,4 @@ });

assert.strictEqual(bytesRead, expected.length);
assert.strictEqual(bufferAsync.toString(), expected);
assert.equal(bytesRead, expected.length);
assert.equal(bufferAsync.toString(), expected);
});

@@ -58,4 +58,4 @@

assert.strictEqual(bufferSync.toString(), expected);
assert.strictEqual(bytesRead, expected.length);
assert.equal(bufferSync.toString(), expected);
assert.equal(bytesRead, expected.length);
});

@@ -68,5 +68,5 @@

assert.strictEqual(buffer.subarray(10, buffer.length).toString(), expected);
assert.strictEqual(bytesRead, expected.length);
assert.equal(buffer.subarray(10, buffer.length).toString(), expected);
assert.equal(bytesRead, expected.length);
});
});

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -13,3 +13,3 @@ import { fs } from '../common.js';

const { bytesRead } = await handle.read(new Uint8Array(10), 0, 10, 10000);
assert.strictEqual(bytesRead, 0);
assert.equal(bytesRead, 0);
});

@@ -50,3 +50,3 @@ });

const data: string = await fs.promises.readFile(fn, 'utf8');
assert.strictEqual(data, '');
assert.equal(data, '');
});

@@ -61,3 +61,3 @@

const data: string = fs.readFileSync(fn, 'utf8');
assert.strictEqual(data, '');
assert.equal(data, '');
});

@@ -71,7 +71,7 @@ });

for (let i = 0; i < content.length; i++) {
assert.strictEqual(content[i], '…');
assert.equal(content[i], '…');
}
assert.strictEqual(content.length, 10000);
assert.equal(content.length, 10000);
});
});

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -24,6 +24,6 @@ import { ErrnoError } from '../../dist/error.js';

const contents = await fs.promises.readdir(dir);
assert.strictEqual(contents.length, 2);
assert.equal(contents.length, 2);
const subContents = await fs.promises.readdir(dir + '/_rename_me');
assert.strictEqual(subContents.length, 1);
assert.equal(subContents.length, 1);

@@ -75,4 +75,4 @@ assert(await fs.promises.exists(dir + '/file.dat'));

test('File to Directory and Directory to File Rename', async () => {
const dir = '/rename_filedir_test';
const file = '/rename_filedir_test.txt';
const dir = '/rename_file_dir_test';
const file = '/rename_file_dir_test.txt';

@@ -84,19 +84,9 @@ await fs.promises.mkdir(dir);

assert(error instanceof ErrnoError);
assert(error.code === 'EISDIR' || error.code === 'EPERM');
assert.match(error.code, /EISDIR|EPERM/);
});
// JV: Removing test for now. I noticed that you can do that in Node v0.12 on Mac,
// but it might be FS independent.
/*fs.rename(dir, file, function (e) {
if (e == null) {
throw new Error("Failed invariant: Cannot rename a directory over a file.");
} else {
assert.strictEqual(e.code, 'ENOTDIR');
}
});*/
});
test('rename directory inside itself', async () => {
const renDir1 = '/renamedir_1';
const renDir2 = '/renamedir_1/lol';
const renDir1 = '/rename_dir_1';
const renDir2 = '/rename_dir_1/lol';

@@ -107,5 +97,5 @@ await fs.promises.mkdir(renDir1);

assert(error instanceof ErrnoError);
assert.strictEqual(error.code, 'EBUSY');
assert.equal(error.code, 'EBUSY');
});
});
});

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -3,0 +3,0 @@ import { credentials } from '../../dist/credentials.js';

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -44,5 +44,5 @@ import { fs } from '../common.js';

const readStream = new fs.ReadStream();
assert.strictEqual(readStream.bytesRead, undefined);
assert.strictEqual(readStream.path, undefined);
assert.strictEqual(readStream.pending, undefined);
assert.equal(readStream.bytesRead, undefined);
assert.equal(readStream.path, undefined);
assert.equal(readStream.pending, undefined);

@@ -54,4 +54,4 @@ // Assign values

assert.strictEqual(readStream.bytesRead, 10);
assert.strictEqual(readStream.path, testFilePath);
assert.equal(readStream.bytesRead, 10);
assert.equal(readStream.path, testFilePath);
assert(!readStream.pending);

@@ -107,5 +107,5 @@ });

const writeStream = new fs.WriteStream();
assert.strictEqual(writeStream.bytesWritten, undefined);
assert.strictEqual(writeStream.path, undefined);
assert.strictEqual(writeStream.pending, undefined);
assert.equal(writeStream.bytesWritten, undefined);
assert.equal(writeStream.path, undefined);
assert.equal(writeStream.pending, undefined);

@@ -117,4 +117,4 @@ // Assign values

assert.strictEqual(writeStream.bytesWritten, 20);
assert.strictEqual(writeStream.path, testFilePathWrite);
assert.equal(writeStream.bytesWritten, 20);
assert.equal(writeStream.path, testFilePathWrite);
assert(writeStream.pending);

@@ -121,0 +121,0 @@ });

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -31,7 +31,7 @@ import { wait } from 'utilium';

assert.deepStrictEqual(unixTimestamps(await fs.promises.stat(path)), times);
assert.deepEqual(unixTimestamps(await fs.promises.stat(path)), times);
await fs.promises.utimes('foobarbaz', atime, mtime).catch((error: ErrnoError) => {
assert(error instanceof ErrnoError);
assert.strictEqual(error.code, 'ENOENT');
assert.equal(error.code, 'ENOENT');
});

@@ -42,6 +42,6 @@

await handle.utimes(atime, mtime);
assert.deepStrictEqual(unixTimestamps(await handle.stat()), times);
assert.deepEqual(unixTimestamps(await handle.stat()), times);
fs.utimesSync(path, atime, mtime);
assert.deepStrictEqual(unixTimestamps(fs.statSync(path)), times);
assert.deepEqual(unixTimestamps(fs.statSync(path)), times);

@@ -52,3 +52,3 @@ try {

assert(error instanceof ErrnoError);
assert.strictEqual(error.code, 'ENOENT');
assert.equal(error.code, 'ENOENT');
}

@@ -55,0 +55,0 @@

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -3,0 +3,0 @@ import { fs } from '../common.js';

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -17,4 +17,4 @@ import { fs, type Stats } from '../common.js';

using watcher = fs.watch(testFile, (eventType, filename) => {
assert.strictEqual(eventType, 'change');
assert.strictEqual(filename, 'test.txt');
assert.equal(eventType, 'change');
assert.equal(filename, 'test.txt');
});

@@ -28,4 +28,4 @@

using watcher = fs.watch(testFile, (eventType, filename) => {
assert.strictEqual(eventType, 'rename');
assert.strictEqual(filename, 'test.txt');
assert.equal(eventType, 'rename');
assert.equal(filename, 'test.txt');
});

@@ -68,4 +68,4 @@

using watcher = fs.watch(testDir, (eventType, filename) => {
assert.strictEqual(eventType, 'change');
assert.strictEqual(filename, 'newFile.txt');
assert.equal(eventType, 'change');
assert.equal(filename, 'newFile.txt');
});

@@ -93,3 +93,3 @@

assert.notEqual(resolver, undefined); // should have a resolver so file is expected
assert.strictEqual(eventType, resolver.eventType);
assert.equal(eventType, resolver.eventType);
resolver.resolver.resolve();

@@ -109,4 +109,4 @@ });

using watcher = fs.watch(tempFile, (eventType, filename) => {
assert.strictEqual(eventType, 'rename');
assert.strictEqual(filename, 'tempFile.txt');
assert.equal(eventType, 'rename');
assert.equal(filename, 'tempFile.txt');
});

@@ -113,0 +113,0 @@

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -12,7 +12,7 @@ import { fs } from '../common.js';

const { bytesWritten } = await handle.write(expected, 0, 'utf8');
assert.strictEqual(bytesWritten, Buffer.from(expected).length);
assert.equal(bytesWritten, Buffer.from(expected).length);
await handle.close();
const data = await fs.promises.readFile(fn, 'utf8');
assert.strictEqual(data, expected);
assert.equal(data, expected);

@@ -29,3 +29,3 @@ await fs.promises.unlink(fn);

assert.strictEqual(expected.length, written.bytesWritten);
assert.equal(expected.length, written.bytesWritten);

@@ -43,3 +43,3 @@ await handle.close();

let written = fs.writeSync(fd, '');
assert.strictEqual(written, 0);
assert.equal(written, 0);

@@ -50,8 +50,8 @@ fs.writeSync(fd, 'foo');

written = fs.writeSync(fd, data, 0, data.length);
assert.strictEqual(written, 4);
assert.equal(written, 4);
fs.closeSync(fd);
assert.strictEqual(fs.readFileSync(fn, 'utf8'), 'foobár');
assert.equal(fs.readFileSync(fn, 'utf8'), 'foobár');
});
});

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -13,3 +13,3 @@ import { fs } from '../common.js';

const data = await fs.promises.readFile(filename);
assert.strictEqual(data.length, Buffer.from(s).length);
assert.equal(data.length, Buffer.from(s).length);
await fs.promises.unlink(filename);

@@ -24,3 +24,3 @@ });

const actual = await fs.promises.readFile(filename);
assert.strictEqual(actual.length, expected.length);
assert.equal(actual.length, expected.length);

@@ -40,3 +40,3 @@ await fs.promises.unlink(filename);

const read = await fs.promises.readFile(filePath, 'base64');
assert.strictEqual(read, data);
assert.equal(read, data);
});

@@ -53,3 +53,3 @@ });

const content = fs.readFileSync(file, 'utf8');
assert.strictEqual(content, '123');
assert.equal(content, '123');
assert((fs.statSync(file).mode & 0o777) === mode);

@@ -67,3 +67,3 @@

const content = fs.readFileSync(file, { encoding: 'utf8' });
assert.strictEqual(content, 'abc');
assert.equal(content, 'abc');

@@ -70,0 +70,0 @@ assert((fs.statSync(file).mode & 0o777) === mode);

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -3,0 +3,0 @@ import { MessageChannel } from 'node:worker_threads';

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { dirname } from 'node:path';

@@ -3,0 +3,0 @@ import { suite, test } from 'node:test';

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { dirname } from 'node:path';

@@ -3,0 +3,0 @@ import { suite, test } from 'node:test';

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

import assert from 'node:assert';
import assert from 'node:assert/strict';
import { suite, test } from 'node:test';

@@ -29,3 +29,3 @@ import { MessageChannel } from 'node:worker_threads';

assert(error! instanceof ErrnoError);
assert.strictEqual(error.code, 'EIO');
assert.equal(error.code, 'EIO');
assert(error.message.includes('RPC Failed'));

@@ -44,3 +44,3 @@ });

assert(error! instanceof ErrnoError);
assert.strictEqual(error.code, 'EIO');
assert.equal(error.code, 'EIO');
assert(error.message.includes('RPC Failed'));

@@ -47,0 +47,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