MCPcopy
hub / github.com/webpack/webpack / _readRecords

Method _readRecords

lib/Compiler.js:1215–1251  ·  view source on GitHub ↗

* Processes the provided error callback. * @param {ErrorCallback} callback signals when the call finishes * @returns {void}

(callback)

Source from the content-addressed store, hash-verified

1213 * @returns {void}
1214 */
1215 _readRecords(callback) {
1216 if (!this.recordsInputPath) {
1217 this.records = {};
1218 return callback(null);
1219 }
1220 /** @type {InputFileSystem} */
1221 (this.inputFileSystem).stat(this.recordsInputPath, (err) => {
1222 // It doesn't exist
1223 // We can ignore this.
1224 if (err) return callback(null);
1225
1226 /** @type {InputFileSystem} */
1227 (this.inputFileSystem).readFile(
1228 /** @type {string} */
1229 (this.recordsInputPath),
1230 (err, content) => {
1231 if (err) return callback(err);
1232
1233 try {
1234 this.records =
1235 /** @type {Records} */
1236 (parseJson(/** @type {Buffer} */ (content).toString("utf8")));
1237 } catch (parseErr) {
1238 return callback(
1239 new Error(
1240 `Cannot parse records: ${
1241 /** @type {Error} */ (parseErr).message
1242 }`
1243 )
1244 );
1245 }
1246
1247 return callback(null);
1248 }
1249 );
1250 });
1251 }
1252
1253 /**
1254 * Creates a child compiler.

Callers 1

readRecordsMethod · 0.95

Calls 4

parseJsonFunction · 0.85
readFileMethod · 0.80
callbackFunction · 0.50
toStringMethod · 0.45

Tested by

no test coverage detected