mem-fs-editor 10.0.1 → 10.0.3

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.
@@ -6,7 +6,7 @@ const defaultDumpFilter = (file) => hasClearedState(file) || hasState(file);
6
6
  export default function (cwd = process.cwd(), filter) {
7
7
  const filterFile = typeof filter === 'string'
8
8
  ? (file) => defaultDumpFilter(file) && minimatch(file.path, filter)
9
- : defaultDumpFilter;
9
+ : filter ?? defaultDumpFilter;
10
10
  return Object.fromEntries(this.store
11
11
  .all()
12
12
  .filter((file) => filterFile(file, cwd))
@@ -0,0 +1,8 @@
1
+ import type { MemFsEditor, MemFsEditorFile } from '../index.js';
2
+ import { type PipelineOptions as MemFsPipelineOptions, type FileTransform as MemFsFileTransform } from 'mem-fs';
3
+ export type PipelineOptions<EditorFile extends MemFsEditorFile> = MemFsPipelineOptions<EditorFile> & {
4
+ pendingFiles?: boolean;
5
+ };
6
+ export type FileTransform<EditorFile extends MemFsEditorFile> = MemFsFileTransform<EditorFile>;
7
+ declare function pipeline<EditorFile extends MemFsEditorFile>(this: MemFsEditor<EditorFile>, options?: PipelineOptions<EditorFile> | FileTransform<EditorFile>, ...transforms: FileTransform<EditorFile>[]): Promise<void>;
8
+ export default pipeline;
@@ -0,0 +1,27 @@
1
+ import { isFileTransform, } from 'mem-fs';
2
+ import { isFilePending } from '../state.js';
3
+ async function pipeline(options, ...transforms) {
4
+ let storeOptions = { filter: isFilePending };
5
+ if (isFileTransform(options)) {
6
+ transforms = [options, ...transforms];
7
+ storeOptions = { filter: isFilePending };
8
+ }
9
+ else if (options) {
10
+ const { pendingFiles = true, ...pipelineOptions } = options;
11
+ if (pipelineOptions.filter) {
12
+ const optionsfilter = pipelineOptions.filter;
13
+ if (pendingFiles) {
14
+ pipelineOptions.filter = (file) => optionsfilter(file) && isFilePending(file);
15
+ }
16
+ else {
17
+ pipelineOptions.filter = optionsfilter;
18
+ }
19
+ }
20
+ else {
21
+ pipelineOptions.filter = pendingFiles ? isFilePending : undefined;
22
+ }
23
+ storeOptions = pipelineOptions;
24
+ }
25
+ await this.store.pipeline(storeOptions, ...transforms);
26
+ }
27
+ export default pipeline;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mem-fs-editor",
3
- "version": "10.0.1",
3
+ "version": "10.0.3",
4
4
  "description": "File edition helpers working on top of mem-fs",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -60,7 +60,10 @@
60
60
  "typescript": "^5.0.4",
61
61
  "vitest": "^0.30.1"
62
62
  },
63
+ "acceptDependencies": {
64
+ "mem-fs": "^4.0.0"
65
+ },
63
66
  "engines": {
64
- "node": ">=12.10.0"
67
+ "node": ">=16.13.0"
65
68
  }
66
69
  }