7
7
addToLibrary ( {
8
8
$NODERAWFS__deps : [ '$ERRNO_CODES' , '$FS' , '$NODEFS' , '$mmapAlloc' , '$FS_modeStringToFlags' ] ,
9
9
$NODERAWFS__postset : `
10
- if (ENVIRONMENT_IS_NODE) {
10
+ if (!ENVIRONMENT_IS_NODE) {
11
+ throw new Error("NODERAWFS is currently only supported on Node.js environment.")
12
+ }
13
+ // Use this to reference our in-memory filesystem
14
+ var VFS = Object.assign({}, FS);
15
+ // Override the init function with our own
16
+ FS.init = NODERAWFS.init;` ,
17
+ $NODERAWFS : {
18
+ init ( input , output , error ) {
19
+ // Call the original FS.init, this will setup the
20
+ // stdin, stdout and stderr devices
21
+ VFS . init ( input , output , error ) ;
22
+
11
23
var _wrapNodeError = function ( func ) {
12
24
return function ( ...args ) {
13
25
try {
@@ -20,15 +32,14 @@ addToLibrary({
20
32
}
21
33
}
22
34
} ;
23
- /** @suppress {partialAlias} */
24
- var VFS = Object.assign({}, FS);
35
+
36
+ // Wrap the whole in-memory filesystem API with
37
+ // our Node.js based functions
25
38
for ( var _key in NODERAWFS ) {
39
+ /** @suppress {partialAlias} */
26
40
FS [ _key ] = _wrapNodeError ( NODERAWFS [ _key ] ) ;
27
41
}
28
- } else {
29
- throw new Error("NODERAWFS is currently only supported on Node.js environment.")
30
- }` ,
31
- $NODERAWFS : {
42
+ } ,
32
43
lookup ( parent , name ) {
33
44
#if ASSERTIONS
34
45
assert ( parent )
@@ -44,12 +55,6 @@ addToLibrary({
44
55
var mode = NODEFS . getMode ( path ) ;
45
56
return { path, node : { id : st . ino , mode, node_ops : NODERAWFS , path } } ;
46
57
} ,
47
- createStandardStreams ( ) {
48
- FS . createStream ( { nfd : 0 , position : 0 , path : '' , flags : 0 , tty : true , seekable : false } , 0 ) ;
49
- for ( var i = 1 ; i < 3 ; i ++ ) {
50
- FS . createStream ( { nfd : i , position : 0 , path : '' , flags : 577 , tty : true , seekable : false } , i ) ;
51
- }
52
- } ,
53
58
// generic function for all node creation
54
59
cwd ( ) { return process . cwd ( ) ; } ,
55
60
chdir ( ...args ) { process . chdir ( ...args ) ; } ,
0 commit comments