@zenfs/core 1.6.14 → 1.6.16

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.
@@ -7,7 +7,7 @@ import { Stats } from '../stats.js';
7
7
  * @internal
8
8
  */
9
9
  export interface IndexData {
10
- version: 1;
10
+ version: number;
11
11
  entries: Record<string, StatsLike<number>>;
12
12
  }
13
13
  export declare const version = 1;
@@ -926,9 +926,10 @@ export async function realpath(path, options) {
926
926
  }
927
927
  realpath;
928
928
  export function watch(filename, options = {}) {
929
+ const context = this;
929
930
  return {
930
931
  [Symbol.asyncIterator]() {
931
- const watcher = new FSWatcher(this, filename.toString(), typeof options !== 'string' ? options : { encoding: options });
932
+ const watcher = new FSWatcher(context, filename.toString(), typeof options !== 'string' ? options : { encoding: options });
932
933
  // A queue to hold change events, since we need to resolve them in the async iterator
933
934
  const eventQueue = [];
934
935
  watcher.on('change', (eventType, filename) => {
package/eslint.shared.js CHANGED
@@ -40,9 +40,9 @@ export default [
40
40
  '@typescript-eslint/no-unsafe-member-access': 'off',
41
41
  '@typescript-eslint/no-unsafe-argument': 'off',
42
42
  '@typescript-eslint/no-unsafe-assignment': 'off',
43
- '@typescript-eslint/no-unsafe-return': 'warn',
43
+ '@typescript-eslint/no-unsafe-return': 'off',
44
44
  '@typescript-eslint/no-redundant-type-constituents': 'warn',
45
- '@typescript-eslint/no-unsafe-call': 'warn',
45
+ '@typescript-eslint/no-unsafe-call': 'off',
46
46
  '@typescript-eslint/restrict-plus-operands': 'off',
47
47
  '@typescript-eslint/no-base-to-string': 'off',
48
48
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenfs/core",
3
- "version": "1.6.14",
3
+ "version": "1.6.16",
4
4
  "description": "A filesystem, anywhere",
5
5
  "funding": {
6
6
  "type": "individual",
@@ -16,4 +16,21 @@ suite('Context', () => {
16
16
  test('break-out fails', () => {
17
17
  assert.deepEqual(c_fs.readdirSync('/../../'), ['example.txt']);
18
18
  });
19
+
20
+ test('watch should consider context', async () => {
21
+ let lastFile: string,
22
+ events = 0;
23
+ const watcher = c_fs.promises.watch('/', { recursive: true });
24
+
25
+ (async () => {
26
+ for await (const event of watcher) {
27
+ lastFile = event.filename!;
28
+ if (++events == 2) return;
29
+ }
30
+ })();
31
+ await c_fs.promises.writeFile('/xpto.txt', 'in real root');
32
+ assert.strictEqual(lastFile!, 'xpto.txt');
33
+ await c_fs.promises.unlink('/xpto.txt');
34
+ assert.strictEqual(lastFile, 'xpto.txt');
35
+ });
19
36
  });