memfs 4.56.10 → 4.57.0
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/lib/index.d.ts +12 -4
- package/lib/index.js +9 -4
- package/lib/index.js.map +1 -1
- package/package.json +9 -9
package/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Stats, Dirent, Volume, StatWatcher, FSWatcher } from '@jsonjoy.com/fs-node';
|
|
2
2
|
import type { IWriteStream } from '@jsonjoy.com/fs-node';
|
|
3
|
-
import { DirectoryJSON, NestedDirectoryJSON } from '@jsonjoy.com/fs-core';
|
|
3
|
+
import { DirectoryJSON, NestedDirectoryJSON, type IProcess } from '@jsonjoy.com/fs-core';
|
|
4
4
|
import { constants } from '@jsonjoy.com/fs-node-utils';
|
|
5
5
|
import type { FsPromisesApi } from '@jsonjoy.com/fs-node-utils';
|
|
6
6
|
import type * as misc from '@jsonjoy.com/fs-node-utils/lib/types/misc';
|
|
7
7
|
export { DirectoryJSON, NestedDirectoryJSON, Volume };
|
|
8
|
+
export type { IProcess };
|
|
8
9
|
export declare const vol: Volume;
|
|
9
10
|
export interface IFs extends Volume {
|
|
10
11
|
constants: typeof constants;
|
|
@@ -19,17 +20,24 @@ export interface IFs extends Volume {
|
|
|
19
20
|
}
|
|
20
21
|
export declare function createFsFromVolume(vol: Volume): IFs;
|
|
21
22
|
export declare const fs: IFs;
|
|
23
|
+
/** Options for creating a memfs instance. */
|
|
24
|
+
export interface MemfsOptions {
|
|
25
|
+
/** Custom working directory for resolving relative paths. Defaults to `'/'`. */
|
|
26
|
+
cwd?: string;
|
|
27
|
+
/** Custom `process`-like object for controlling platform, uid, gid, and cwd behavior. */
|
|
28
|
+
process?: IProcess;
|
|
29
|
+
}
|
|
22
30
|
/**
|
|
23
31
|
* Creates a new file system instance.
|
|
24
32
|
*
|
|
25
33
|
* @param json File system structure expressed as a JSON object.
|
|
26
34
|
* Use `null` for empty directories and empty string for empty files.
|
|
27
|
-
* @param
|
|
28
|
-
* relative to
|
|
35
|
+
* @param cwdOrOpts Current working directory (string) or options object.
|
|
36
|
+
* The JSON structure will be created relative to the cwd path.
|
|
29
37
|
* @returns A `memfs` file system instance, which is a drop-in replacement for
|
|
30
38
|
* the `fs` module.
|
|
31
39
|
*/
|
|
32
|
-
export declare const memfs: (json?: NestedDirectoryJSON,
|
|
40
|
+
export declare const memfs: (json?: NestedDirectoryJSON, cwdOrOpts?: string | MemfsOptions) => {
|
|
33
41
|
fs: IFs;
|
|
34
42
|
vol: Volume;
|
|
35
43
|
};
|
package/lib/index.js
CHANGED
|
@@ -45,13 +45,18 @@ exports.fs = createFsFromVolume(exports.vol);
|
|
|
45
45
|
*
|
|
46
46
|
* @param json File system structure expressed as a JSON object.
|
|
47
47
|
* Use `null` for empty directories and empty string for empty files.
|
|
48
|
-
* @param
|
|
49
|
-
* relative to
|
|
48
|
+
* @param cwdOrOpts Current working directory (string) or options object.
|
|
49
|
+
* The JSON structure will be created relative to the cwd path.
|
|
50
50
|
* @returns A `memfs` file system instance, which is a drop-in replacement for
|
|
51
51
|
* the `fs` module.
|
|
52
52
|
*/
|
|
53
|
-
const memfs = (json = {},
|
|
54
|
-
const
|
|
53
|
+
const memfs = (json = {}, cwdOrOpts = '/') => {
|
|
54
|
+
const opts = typeof cwdOrOpts === 'string' ? { cwd: cwdOrOpts } : cwdOrOpts;
|
|
55
|
+
// When no explicit cwd is given but a custom process is provided, let the
|
|
56
|
+
// Superblock use that process's cwd(). Otherwise default to '/' so the
|
|
57
|
+
// convenience function keeps its opinionated virtual-root default.
|
|
58
|
+
const cwd = opts.cwd ?? (opts.process ? undefined : '/');
|
|
59
|
+
const vol = fs_node_1.Volume.fromNestedJSON(json, cwd, { process: opts.process });
|
|
55
60
|
const fs = createFsFromVolume(vol);
|
|
56
61
|
return { fs, vol };
|
|
57
62
|
};
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAoCA,gDA+BC;AAnED,kDAS8B;AASe,uFAf3C,gBAAM,OAe2C;AANnD,8DAAuD;AAIvD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,yBAAS,CAAC;AAK7C,kBAAkB;AACL,QAAA,GAAG,GAAG,IAAI,gBAAM,EAAE,CAAC;AAchC,SAAgB,kBAAkB,CAAC,GAAW;IAC5C,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAT,yBAAS,EAAE,KAAK,EAAL,eAAK,EAAE,MAAM,EAAN,gBAAM,EAAgB,CAAC;IAE9E,mBAAmB;IACnB,KAAK,MAAM,MAAM,IAAI,8BAAoB;QAAE,IAAI,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,UAAU;YAAE,EAAE,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrH,KAAK,MAAM,MAAM,IAAI,2BAAiB;QAAE,IAAI,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,UAAU;YAAE,EAAE,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAElH,EAAE,CAAC,WAAW,GAAG,GAAG,CAAC,WAAW,CAAC;IACjC,EAAE,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC;IAC7B,EAAE,CAAC,WAAW,GAAG,GAAG,CAAC,WAAW,CAAC;IACjC,EAAE,CAAC,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC;IAC/B,EAAE,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;IAE3B,iEAAiE;IACjE,I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AC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACzD,MAAM,GAAG,GAAG,gBAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IACxE,MAAM,EAAE,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACnC,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC;AACrB,CAAC,CAAC;AAZW,QAAA,KAAK,SAYhB;AAKF,MAAM,CAAC,OAAO,GAAG,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,UAAE,EAAE,CAAC;AAC9C,MAAM,CAAC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "memfs",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.57.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -127,14 +127,14 @@
|
|
|
127
127
|
"tslib": "2"
|
|
128
128
|
},
|
|
129
129
|
"dependencies": {
|
|
130
|
-
"@jsonjoy.com/fs-core": "4.
|
|
131
|
-
"@jsonjoy.com/fs-fsa": "4.
|
|
132
|
-
"@jsonjoy.com/fs-node": "4.
|
|
133
|
-
"@jsonjoy.com/fs-node-builtins": "4.
|
|
134
|
-
"@jsonjoy.com/fs-node-to-fsa": "4.
|
|
135
|
-
"@jsonjoy.com/fs-node-utils": "4.
|
|
136
|
-
"@jsonjoy.com/fs-print": "4.
|
|
137
|
-
"@jsonjoy.com/fs-snapshot": "4.
|
|
130
|
+
"@jsonjoy.com/fs-core": "4.57.0",
|
|
131
|
+
"@jsonjoy.com/fs-fsa": "4.57.0",
|
|
132
|
+
"@jsonjoy.com/fs-node": "4.57.0",
|
|
133
|
+
"@jsonjoy.com/fs-node-builtins": "4.57.0",
|
|
134
|
+
"@jsonjoy.com/fs-node-to-fsa": "4.57.0",
|
|
135
|
+
"@jsonjoy.com/fs-node-utils": "4.57.0",
|
|
136
|
+
"@jsonjoy.com/fs-print": "4.57.0",
|
|
137
|
+
"@jsonjoy.com/fs-snapshot": "4.57.0",
|
|
138
138
|
"@jsonjoy.com/json-pack": "^1.11.0",
|
|
139
139
|
"@jsonjoy.com/util": "^1.9.0",
|
|
140
140
|
"glob-to-regex.js": "^1.0.1",
|