Repository navigation
Expand file tree
/
Copy pathvfs.js
More file actions
57 lines (51 loc) · 1.82 KB
/
Copy pathvfs.js
File metadata and controls
57 lines (51 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
'use strict';
const {
FunctionPrototypeSymbolHasInstance,
} = primordials;
const { emitExperimentalWarning } = require('internal/util');
emitExperimentalWarning('VirtualFileSystem');
const { VirtualFileSystem } = require('internal/vfs/file_system');
const { VirtualProvider } = require('internal/vfs/provider');
const { MemoryProvider } = require('internal/vfs/providers/memory');
const { ComposableProvider } = require('internal/vfs/providers/composable');
const { RealFSProvider } = require('internal/vfs/providers/real');
const { ZipProvider } = require('internal/vfs/providers/ziparchive');
const { registerProvider } = require('internal/vfs/provider_registry');
const { getVfsRoot } = require('internal/vfs/router');
/**
* Creates a new VirtualFileSystem instance.
* @param {VirtualProvider} [provider] The provider to use (defaults to MemoryProvider)
* @param {object} [options] Configuration options
* @param {boolean} [options.moduleHooks] Whether to enable require/import hooks (default: true)
* @param {boolean} [options.virtualCwd] Whether to enable virtual working directory
* @returns {VirtualFileSystem}
*/
function create(provider, options) {
// Handle case where first arg is options (no provider)
if (provider != null &&
!FunctionPrototypeSymbolHasInstance(VirtualProvider, provider) &&
typeof provider === 'object') {
options = provider;
provider = undefined;
}
return new VirtualFileSystem(provider, options);
}
/**
* Returns the directory that holds the mount points of every mounted virtual
* file system.
* @returns {string} The absolute path of the reserved root directory
*/
function vfsBase() {
return getVfsRoot();
}
module.exports = {
create,
vfsBase,
registerProvider,
VirtualFileSystem,
VirtualProvider,
MemoryProvider,
ComposableProvider,
RealFSProvider,
ZipProvider,
};