MCPcopy Index your code
hub / github.com/nodejs/node / readFile

Method readFile

lib/internal/test_runner/snapshot.js:90–116  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

88 }
89
90 readFile() {
91 if (this.loaded) {
92 debug('skipping read of snapshot file');
93 return;
94 }
95
96 try {
97 const source = readFileSync(this.snapshotFile, 'utf8');
98 const context = { __proto__: null, exports: { __proto__: null } };
99
100 createContext(context);
101 runInContext(source, context);
102
103 if (context.exports === null || typeof context.exports !== 'object') {
104 throw new ERR_INVALID_STATE(
105 `Malformed snapshot file '${this.snapshotFile}'.`,
106 );
107 }
108
109 for (const key in context.exports) {
110 this.snapshots[key] = templateEscape(context.exports[key]);
111 }
112 this.loaded = true;
113 } catch (err) {
114 throwReadError(err, this.snapshotFile);
115 }
116 }
117
118 writeFile() {
119 try {

Callers 1

createAssertMethod · 0.45

Calls 6

createContextFunction · 0.85
runInContextFunction · 0.85
templateEscapeFunction · 0.85
throwReadErrorFunction · 0.85
debugFunction · 0.50
readFileSyncFunction · 0.50

Tested by

no test coverage detected