@zenfs/core 2.3.0 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backends/single_buffer.d.ts +0 -2
- package/dist/backends/single_buffer.js +4 -10
- package/dist/internal/inode.d.ts +0 -2
- package/dist/internal/inode.js +4 -10
- package/dist/vfs/acl.d.ts +0 -2
- package/dist/vfs/acl.js +4 -10
- package/dist/vfs/promises.d.ts +7 -9
- package/dist/vfs/promises.js +22 -16
- package/package.json +2 -2
- package/scripts/test.js +11 -8
- package/tests/fs/read.test.ts +24 -1
|
@@ -23,7 +23,6 @@ declare class MetadataEntry extends BufferView {
|
|
|
23
23
|
* This is done since IDs are not guaranteed to be sequential.
|
|
24
24
|
*/
|
|
25
25
|
export declare class MetadataBlock extends Int32Array<ArrayBufferLike> {
|
|
26
|
-
static readonly name = "MetadataBlock";
|
|
27
26
|
readonly ['constructor']: typeof MetadataBlock;
|
|
28
27
|
/**
|
|
29
28
|
* The crc32c checksum for the metadata block.
|
|
@@ -55,7 +54,6 @@ export declare class MetadataBlock extends Int32Array<ArrayBufferLike> {
|
|
|
55
54
|
* The super block structure for a single-buffer file system
|
|
56
55
|
*/
|
|
57
56
|
export declare class SuperBlock extends BigUint64Array<ArrayBufferLike> {
|
|
58
|
-
static readonly name = "SuperBlock";
|
|
59
57
|
readonly ['constructor']: typeof SuperBlock;
|
|
60
58
|
constructor(...args: ConstructorParameters<typeof BigUint64Array<ArrayBufferLike>>);
|
|
61
59
|
/**
|
|
@@ -177,7 +177,7 @@ const max_lock_attempts = 5;
|
|
|
177
177
|
*/
|
|
178
178
|
let MetadataBlock = (() => {
|
|
179
179
|
var _a, _b, _c, _d;
|
|
180
|
-
let _classDecorators = [struct(packed)];
|
|
180
|
+
let _classDecorators = [struct(packed, { name: 'MetadataBlock' })];
|
|
181
181
|
let _classDescriptor;
|
|
182
182
|
let _classExtraInitializers = [];
|
|
183
183
|
let _classThis;
|
|
@@ -214,8 +214,8 @@ let MetadataBlock = (() => {
|
|
|
214
214
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
215
215
|
MetadataBlock = _classThis = _classDescriptor.value;
|
|
216
216
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
217
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
217
218
|
}
|
|
218
|
-
static name = 'MetadataBlock';
|
|
219
219
|
#checksum_accessor_storage = __runInitializers(this, _checksum_initializers, void 0);
|
|
220
220
|
/**
|
|
221
221
|
* The crc32c checksum for the metadata block.
|
|
@@ -304,9 +304,6 @@ let MetadataBlock = (() => {
|
|
|
304
304
|
super(...arguments);
|
|
305
305
|
__runInitializers(this, _locked_extraInitializers);
|
|
306
306
|
}
|
|
307
|
-
static {
|
|
308
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
309
|
-
}
|
|
310
307
|
};
|
|
311
308
|
return MetadataBlock = _classThis;
|
|
312
309
|
})();
|
|
@@ -322,7 +319,7 @@ const usedBytes = 2;
|
|
|
322
319
|
*/
|
|
323
320
|
let SuperBlock = (() => {
|
|
324
321
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
325
|
-
let _classDecorators = [struct(packed)];
|
|
322
|
+
let _classDecorators = [struct(packed, { name: 'SuperBlock' })];
|
|
326
323
|
let _classDescriptor;
|
|
327
324
|
let _classExtraInitializers = [];
|
|
328
325
|
let _classThis;
|
|
@@ -399,8 +396,8 @@ let SuperBlock = (() => {
|
|
|
399
396
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
400
397
|
SuperBlock = _classThis = _classDescriptor.value;
|
|
401
398
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
399
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
402
400
|
}
|
|
403
|
-
static name = 'SuperBlock';
|
|
404
401
|
constructor(...args) {
|
|
405
402
|
super(...args);
|
|
406
403
|
__runInitializers(this, __padding_extraInitializers);
|
|
@@ -533,9 +530,6 @@ let SuperBlock = (() => {
|
|
|
533
530
|
}
|
|
534
531
|
return true;
|
|
535
532
|
}
|
|
536
|
-
static {
|
|
537
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
538
|
-
}
|
|
539
533
|
};
|
|
540
534
|
return SuperBlock = _classThis;
|
|
541
535
|
})();
|
package/dist/internal/inode.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ export declare const rootIno = 0;
|
|
|
12
12
|
* @internal
|
|
13
13
|
*/
|
|
14
14
|
export declare class Attributes extends BufferView {
|
|
15
|
-
static readonly name = "Attributes";
|
|
16
15
|
accessor size: number;
|
|
17
16
|
['constructor']: typeof Attributes;
|
|
18
17
|
get byteSize(): number;
|
|
@@ -107,7 +106,6 @@ export declare const userModifiableFlags = 229631;
|
|
|
107
106
|
* @internal
|
|
108
107
|
*/
|
|
109
108
|
export declare class Inode extends BufferView implements InodeLike {
|
|
110
|
-
static readonly name = "Inode";
|
|
111
109
|
constructor(...args: ConstructorParameters<typeof BufferView> | [Readonly<Partial<InodeLike>>]);
|
|
112
110
|
accessor data: number;
|
|
113
111
|
/** For future use */
|
package/dist/internal/inode.js
CHANGED
|
@@ -120,7 +120,7 @@ let Attribute = (() => {
|
|
|
120
120
|
*/
|
|
121
121
|
let Attributes = (() => {
|
|
122
122
|
var _a;
|
|
123
|
-
let _classDecorators = [struct(packed)];
|
|
123
|
+
let _classDecorators = [struct(packed, { name: 'Attributes' })];
|
|
124
124
|
let _classDescriptor;
|
|
125
125
|
let _classExtraInitializers = [];
|
|
126
126
|
let _classThis;
|
|
@@ -137,8 +137,8 @@ let Attributes = (() => {
|
|
|
137
137
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
138
138
|
Attributes = _classThis = _classDescriptor.value;
|
|
139
139
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
140
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
140
141
|
}
|
|
141
|
-
static name = 'Attributes';
|
|
142
142
|
#size_accessor_storage = __runInitializers(this, _size_initializers, void 0);
|
|
143
143
|
get size() { return this.#size_accessor_storage; }
|
|
144
144
|
set size(value) { this.#size_accessor_storage = value; }
|
|
@@ -241,9 +241,6 @@ let Attributes = (() => {
|
|
|
241
241
|
super(...arguments);
|
|
242
242
|
__runInitializers(this, _size_extraInitializers);
|
|
243
243
|
}
|
|
244
|
-
static {
|
|
245
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
246
|
-
}
|
|
247
244
|
};
|
|
248
245
|
return Attributes = _classThis;
|
|
249
246
|
})();
|
|
@@ -331,7 +328,7 @@ export const userModifiableFlags = 0x000380ff;
|
|
|
331
328
|
*/
|
|
332
329
|
let Inode = (() => {
|
|
333
330
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
334
|
-
let _classDecorators = [struct(packed)];
|
|
331
|
+
let _classDecorators = [struct(packed, { name: 'Inode' })];
|
|
335
332
|
let _classDescriptor;
|
|
336
333
|
let _classExtraInitializers = [];
|
|
337
334
|
let _classThis;
|
|
@@ -438,8 +435,8 @@ let Inode = (() => {
|
|
|
438
435
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
439
436
|
Inode = _classThis = _classDescriptor.value;
|
|
440
437
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
438
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
441
439
|
}
|
|
442
|
-
static name = 'Inode';
|
|
443
440
|
constructor(...args) {
|
|
444
441
|
let data = {};
|
|
445
442
|
if (typeof args[0] === 'object' && args[0] !== null && !ArrayBuffer.isView(args[0])) {
|
|
@@ -589,9 +586,6 @@ let Inode = (() => {
|
|
|
589
586
|
this.ctimeMs = Date.now();
|
|
590
587
|
return hasChanged;
|
|
591
588
|
}
|
|
592
|
-
static {
|
|
593
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
594
|
-
}
|
|
595
589
|
};
|
|
596
590
|
return Inode = _classThis;
|
|
597
591
|
})();
|
package/dist/vfs/acl.d.ts
CHANGED
|
@@ -18,13 +18,11 @@ export declare const enum Tag {
|
|
|
18
18
|
_None = 0
|
|
19
19
|
}
|
|
20
20
|
export declare class Entry extends BufferView {
|
|
21
|
-
static readonly name = "Entry";
|
|
22
21
|
accessor tag: Tag;
|
|
23
22
|
accessor perm: number;
|
|
24
23
|
accessor id: number;
|
|
25
24
|
}
|
|
26
25
|
export declare class ACL extends BufferView {
|
|
27
|
-
static readonly name = "ACL";
|
|
28
26
|
accessor version: number;
|
|
29
27
|
entries: Entry[];
|
|
30
28
|
constructor(...args: ConstructorParameters<typeof BufferView>);
|
package/dist/vfs/acl.js
CHANGED
|
@@ -67,7 +67,7 @@ export var Tag;
|
|
|
67
67
|
})(Tag || (Tag = {}));
|
|
68
68
|
let Entry = (() => {
|
|
69
69
|
var _a, _b, _c;
|
|
70
|
-
let _classDecorators = [struct(packed)];
|
|
70
|
+
let _classDecorators = [struct(packed, { name: 'Entry' })];
|
|
71
71
|
let _classDescriptor;
|
|
72
72
|
let _classExtraInitializers = [];
|
|
73
73
|
let _classThis;
|
|
@@ -94,8 +94,8 @@ let Entry = (() => {
|
|
|
94
94
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
95
95
|
Entry = _classThis = _classDescriptor.value;
|
|
96
96
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
97
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
97
98
|
}
|
|
98
|
-
static name = 'Entry';
|
|
99
99
|
#tag_accessor_storage = __runInitializers(this, _tag_initializers, void 0);
|
|
100
100
|
get tag() { return this.#tag_accessor_storage; }
|
|
101
101
|
set tag(value) { this.#tag_accessor_storage = value; }
|
|
@@ -109,16 +109,13 @@ let Entry = (() => {
|
|
|
109
109
|
super(...arguments);
|
|
110
110
|
__runInitializers(this, _id_extraInitializers);
|
|
111
111
|
}
|
|
112
|
-
static {
|
|
113
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
114
|
-
}
|
|
115
112
|
};
|
|
116
113
|
return Entry = _classThis;
|
|
117
114
|
})();
|
|
118
115
|
export { Entry };
|
|
119
116
|
let ACL = (() => {
|
|
120
117
|
var _a;
|
|
121
|
-
let _classDecorators = [struct(packed)];
|
|
118
|
+
let _classDecorators = [struct(packed, { name: 'ACL' })];
|
|
122
119
|
let _classDescriptor;
|
|
123
120
|
let _classExtraInitializers = [];
|
|
124
121
|
let _classThis;
|
|
@@ -135,8 +132,8 @@ let ACL = (() => {
|
|
|
135
132
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
136
133
|
ACL = _classThis = _classDescriptor.value;
|
|
137
134
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
135
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
138
136
|
}
|
|
139
|
-
static name = 'ACL';
|
|
140
137
|
#version_accessor_storage = __runInitializers(this, _version_initializers, void 0);
|
|
141
138
|
get version() { return this.#version_accessor_storage; }
|
|
142
139
|
set version(value) { this.#version_accessor_storage = value; }
|
|
@@ -152,9 +149,6 @@ let ACL = (() => {
|
|
|
152
149
|
this.entries.push(new Entry(this.buffer, offset));
|
|
153
150
|
}
|
|
154
151
|
}
|
|
155
|
-
static {
|
|
156
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
157
|
-
}
|
|
158
152
|
};
|
|
159
153
|
return ACL = _classThis;
|
|
160
154
|
})();
|
package/dist/vfs/promises.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { FileContents, ReaddirOptions } from './types.js';
|
|
|
11
11
|
import { Buffer } from 'buffer';
|
|
12
12
|
import '../polyfills.js';
|
|
13
13
|
import { Dir, Dirent } from './dir.js';
|
|
14
|
+
import { SyncHandle } from './file.js';
|
|
14
15
|
import { BigIntStats, Stats } from './stats.js';
|
|
15
16
|
import { ReadStream, WriteStream } from './streams.js';
|
|
16
17
|
export * as constants from './constants.js';
|
|
@@ -18,10 +19,6 @@ export declare class FileHandle implements promises.FileHandle {
|
|
|
18
19
|
protected context: V_Context;
|
|
19
20
|
readonly fd: number;
|
|
20
21
|
protected _buffer?: Uint8Array;
|
|
21
|
-
/**
|
|
22
|
-
* Current position
|
|
23
|
-
*/
|
|
24
|
-
protected _position: number;
|
|
25
22
|
/**
|
|
26
23
|
* Get the current file position.
|
|
27
24
|
*
|
|
@@ -42,15 +39,16 @@ export declare class FileHandle implements promises.FileHandle {
|
|
|
42
39
|
*/
|
|
43
40
|
protected closed: boolean;
|
|
44
41
|
/** The path relative to the context's root */
|
|
45
|
-
|
|
42
|
+
get path(): string;
|
|
46
43
|
/** The internal FS associated with the handle */
|
|
47
|
-
protected
|
|
44
|
+
protected get fs(): FileSystem;
|
|
48
45
|
/** The path relative to the `FileSystem`'s root */
|
|
49
|
-
|
|
46
|
+
get internalPath(): string;
|
|
50
47
|
/** The flag the handle was opened with */
|
|
51
|
-
|
|
48
|
+
get flag(): number;
|
|
52
49
|
/** Stats for the handle */
|
|
53
|
-
|
|
50
|
+
get inode(): InodeLike;
|
|
51
|
+
protected _sync: SyncHandle;
|
|
54
52
|
constructor(context: V_Context, fd: number);
|
|
55
53
|
private get _isSync();
|
|
56
54
|
private _emitChange;
|
package/dist/vfs/promises.js
CHANGED
|
@@ -52,7 +52,7 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
52
52
|
});
|
|
53
53
|
import { Buffer } from 'buffer';
|
|
54
54
|
import { Exception, rethrow, setUVMessage, UV } from 'kerium';
|
|
55
|
-
import { decodeUTF8
|
|
55
|
+
import { decodeUTF8 } from 'utilium';
|
|
56
56
|
import { defaultContext } from '../internal/contexts.js';
|
|
57
57
|
import { hasAccess, InodeFlags, isBlockDevice, isCharacterDevice, isDirectory, isSymbolicLink } from '../internal/inode.js';
|
|
58
58
|
import { dirname, join, matchesGlob, parse, resolve } from '../path.js';
|
|
@@ -73,10 +73,6 @@ export class FileHandle {
|
|
|
73
73
|
context;
|
|
74
74
|
fd;
|
|
75
75
|
_buffer;
|
|
76
|
-
/**
|
|
77
|
-
* Current position
|
|
78
|
-
*/
|
|
79
|
-
_position = 0;
|
|
80
76
|
/**
|
|
81
77
|
* Get the current file position.
|
|
82
78
|
*
|
|
@@ -87,10 +83,10 @@ export class FileHandle {
|
|
|
87
83
|
* @returns The current file position.
|
|
88
84
|
*/
|
|
89
85
|
get position() {
|
|
90
|
-
return this.
|
|
86
|
+
return this._sync.position;
|
|
91
87
|
}
|
|
92
88
|
set position(value) {
|
|
93
|
-
this.
|
|
89
|
+
this._sync.position = value;
|
|
94
90
|
}
|
|
95
91
|
/**
|
|
96
92
|
* Whether the file has changes which have not been written to the FS
|
|
@@ -101,20 +97,30 @@ export class FileHandle {
|
|
|
101
97
|
*/
|
|
102
98
|
closed = false;
|
|
103
99
|
/** The path relative to the context's root */
|
|
104
|
-
path
|
|
100
|
+
get path() {
|
|
101
|
+
return this._sync.path;
|
|
102
|
+
}
|
|
105
103
|
/** The internal FS associated with the handle */
|
|
106
|
-
fs
|
|
104
|
+
get fs() {
|
|
105
|
+
return this._sync.fs;
|
|
106
|
+
}
|
|
107
107
|
/** The path relative to the `FileSystem`'s root */
|
|
108
|
-
internalPath
|
|
108
|
+
get internalPath() {
|
|
109
|
+
return this._sync.internalPath;
|
|
110
|
+
}
|
|
109
111
|
/** The flag the handle was opened with */
|
|
110
|
-
flag
|
|
112
|
+
get flag() {
|
|
113
|
+
return this._sync.flag;
|
|
114
|
+
}
|
|
111
115
|
/** Stats for the handle */
|
|
112
|
-
inode
|
|
116
|
+
get inode() {
|
|
117
|
+
return this._sync.inode;
|
|
118
|
+
}
|
|
119
|
+
_sync;
|
|
113
120
|
constructor(context, fd) {
|
|
114
121
|
this.context = context;
|
|
115
122
|
this.fd = fd;
|
|
116
|
-
|
|
117
|
-
Object.assign(this, pick(sync, 'path', 'fs', 'internalPath', 'flag', 'inode'));
|
|
123
|
+
this._sync = fromFD(context, fd);
|
|
118
124
|
}
|
|
119
125
|
get _isSync() {
|
|
120
126
|
return !!(this.flag & constants.O_SYNC || this.inode.flags & InodeFlags.Sync);
|
|
@@ -246,7 +252,7 @@ export class FileHandle {
|
|
|
246
252
|
if (!isCharacterDevice(this.inode) && !isBlockDevice(this.inode) && end > this.inode.size) {
|
|
247
253
|
end = position + Math.max(this.inode.size - position, 0);
|
|
248
254
|
}
|
|
249
|
-
this.
|
|
255
|
+
this._sync.position = end;
|
|
250
256
|
const uint8 = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
251
257
|
await this.fs.read(this.internalPath, uint8.subarray(offset, offset + length), position, end);
|
|
252
258
|
if (this._isSync)
|
|
@@ -348,7 +354,7 @@ export class FileHandle {
|
|
|
348
354
|
this.inode.size = end;
|
|
349
355
|
this.inode.mtimeMs = Date.now();
|
|
350
356
|
this.inode.ctimeMs = Date.now();
|
|
351
|
-
this.
|
|
357
|
+
this._sync.position = position + slice.byteLength;
|
|
352
358
|
await this.fs.write(this.internalPath, slice, position);
|
|
353
359
|
if (this._isSync)
|
|
354
360
|
await this.sync();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenfs/core",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
4
4
|
"description": "A filesystem, anywhere",
|
|
5
5
|
"funding": {
|
|
6
6
|
"type": "individual",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"buffer": "^6.0.3",
|
|
72
72
|
"eventemitter3": "^5.0.1",
|
|
73
73
|
"kerium": "^1.3.4",
|
|
74
|
-
"memium": "^0.2.
|
|
74
|
+
"memium": "^0.2.3",
|
|
75
75
|
"readable-stream": "^4.5.2",
|
|
76
76
|
"utilium": "^2.3.3"
|
|
77
77
|
},
|
package/scripts/test.js
CHANGED
|
@@ -22,6 +22,7 @@ const { values: options, positionals } = parseArgs({
|
|
|
22
22
|
build: { short: 'b', type: 'boolean', default: false },
|
|
23
23
|
common: { short: 'c', type: 'boolean', default: false },
|
|
24
24
|
inspect: { short: 'I', type: 'boolean', default: false },
|
|
25
|
+
skip: { short: 's', type: 'string' },
|
|
25
26
|
'exit-on-fail': { short: 'e', type: 'boolean' },
|
|
26
27
|
|
|
27
28
|
// Coverage
|
|
@@ -39,13 +40,14 @@ if (options.help) {
|
|
|
39
40
|
Paths: The setup files to run tests on
|
|
40
41
|
|
|
41
42
|
Behavior:
|
|
42
|
-
-a, --auto
|
|
43
|
-
-b, --build
|
|
44
|
-
-c, --common
|
|
45
|
-
-e, --exit-on-fail
|
|
46
|
-
-t, --test <glob>
|
|
47
|
-
-f, --force
|
|
48
|
-
-I, --inspect
|
|
43
|
+
-a, --auto Automatically detect setup files
|
|
44
|
+
-b, --build Run the npm build script prior to running tests
|
|
45
|
+
-c, --common Also run tests not specific to any backend
|
|
46
|
+
-e, --exit-on-fail If any tests suites fail, exit immediately
|
|
47
|
+
-t, --test <glob> Which FS test suite(s) to run
|
|
48
|
+
-f, --force Whether to use --test-force-exit
|
|
49
|
+
-I, --inspect Use the inspector for debugging
|
|
50
|
+
-s, --skip <pattern> Skip tests with names matching the given pattern.
|
|
49
51
|
|
|
50
52
|
Output:
|
|
51
53
|
-h, --help Outputs this help message
|
|
@@ -213,7 +215,8 @@ for (const setupFile of positionals) {
|
|
|
213
215
|
options.inspect ? 'inspect' : '',
|
|
214
216
|
'--test --experimental-test-coverage',
|
|
215
217
|
options.force ? '--test-force-exit' : '',
|
|
216
|
-
|
|
218
|
+
options.skip ? `--test-skip-pattern=${options.skip}` : '',
|
|
219
|
+
`'${testsGlob.replaceAll("'", "\\'")}'`,
|
|
217
220
|
process.env.CMD,
|
|
218
221
|
].join(' '),
|
|
219
222
|
{
|
package/tests/fs/read.test.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Buffer } from 'buffer';
|
|
2
2
|
import assert from 'node:assert/strict';
|
|
3
|
+
import type { OpenMode, PathLike } from 'node:fs';
|
|
3
4
|
import { suite, test } from 'node:test';
|
|
4
|
-
import {
|
|
5
|
+
import { promisify } from 'node:util';
|
|
6
|
+
import { fs, type Callback } from '../common.js';
|
|
5
7
|
|
|
6
8
|
const filepath = 'x.txt';
|
|
7
9
|
const expected = 'xyz\n';
|
|
@@ -65,4 +67,25 @@ suite('read', () => {
|
|
|
65
67
|
assert.equal(buffer.subarray(10, buffer.length).toString(), expected);
|
|
66
68
|
assert.equal(bytesRead, expected.length);
|
|
67
69
|
});
|
|
70
|
+
|
|
71
|
+
test('read using callback API', async () => {
|
|
72
|
+
// @zenfs/core#239
|
|
73
|
+
const path = '/text.txt';
|
|
74
|
+
|
|
75
|
+
fs.writeFileSync(path, 'hello world');
|
|
76
|
+
const fd: number = (await promisify<PathLike, OpenMode, number | string>(fs.open)(path, 0, 0)) as any;
|
|
77
|
+
|
|
78
|
+
const read = promisify(fs.read);
|
|
79
|
+
|
|
80
|
+
const buf = Buffer.alloc(1024);
|
|
81
|
+
const n0 = await read(fd, buf, 0, 1024, undefined);
|
|
82
|
+
assert.equal(n0, 11);
|
|
83
|
+
assert.equal(buf.subarray(0, n0).toString('utf8'), 'hello world');
|
|
84
|
+
|
|
85
|
+
const n1 = await read(fd, buf, 0, 1024, undefined);
|
|
86
|
+
assert.equal(n1, 0);
|
|
87
|
+
assert.equal(buf.subarray(0, n1).toString('utf8'), '');
|
|
88
|
+
|
|
89
|
+
await promisify(fs.close)(fd);
|
|
90
|
+
});
|
|
68
91
|
});
|