77addToLibrary ( {
88 $NODERAWFS__deps : [ '$ERRNO_CODES' , '$FS' , '$NODEFS' , '$mmapAlloc' , '$FS_modeStringToFlags' ] ,
99 $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+
1123 var _wrapNodeError = function ( func ) {
1224 return function ( ...args ) {
1325 try {
@@ -20,15 +32,14 @@ addToLibrary({
2032 }
2133 }
2234 } ;
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
2538 for ( var _key in NODERAWFS ) {
39+ /** @suppress {partialAlias} */
2640 FS [ _key ] = _wrapNodeError ( NODERAWFS [ _key ] ) ;
2741 }
28- } else {
29- throw new Error("NODERAWFS is currently only supported on Node.js environment.")
30- }` ,
31- $NODERAWFS : {
42+ } ,
3243 lookup ( parent , name ) {
3344#if ASSERTIONS
3445 assert ( parent )
@@ -44,12 +55,6 @@ addToLibrary({
4455 var mode = NODEFS . getMode ( path ) ;
4556 return { path, node : { id : st . ino , mode, node_ops : NODERAWFS , path } } ;
4657 } ,
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- } ,
5358 // generic function for all node creation
5459 cwd ( ) { return process . cwd ( ) ; } ,
5560 chdir ( ...args ) { process . chdir ( ...args ) ; } ,
0 commit comments