MCPcopy
hub / github.com/webpack/webpack / runWrite

Method runWrite

lib/schemes/HttpUriPlugin.js:1409–1448  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1407 }
1408 };
1409 const runWrite = () => {
1410 intermediateFs.readFile(lockfileLocation, (err, buffer) => {
1411 if (err && err.code !== "ENOENT") {
1412 writeDone();
1413 return callback(err);
1414 }
1415 const lockfile = buffer
1416 ? Lockfile.parse(buffer.toString("utf8"))
1417 : new Lockfile();
1418 for (const [key, value] of /** @type {LockfileUpdates} */ (
1419 lockfileUpdates
1420 )) {
1421 lockfile.entries.set(key, value);
1422 }
1423 intermediateFs.writeFile(
1424 tempFile,
1425 lockfile.toString(),
1426 (err) => {
1427 if (err) {
1428 writeDone();
1429 return (
1430 /** @type {NonNullable<IntermediateFileSystem["unlink"]>} */
1431 (intermediateFs.unlink)(tempFile, () => callback(err))
1432 );
1433 }
1434 intermediateFs.rename(tempFile, lockfileLocation, (err) => {
1435 if (err) {
1436 writeDone();
1437 return (
1438 /** @type {NonNullable<IntermediateFileSystem["unlink"]>} */
1439 (intermediateFs.unlink)(tempFile, () => callback(err))
1440 );
1441 }
1442 writeDone();
1443 callback();
1444 });
1445 }
1446 );
1447 });
1448 };
1449 if (inProgressWrite) {
1450 inProgressWrite.push(runWrite);
1451 } else {

Callers

nothing calls this directly

Calls 6

readFileMethod · 0.80
callbackFunction · 0.50
parseMethod · 0.45
toStringMethod · 0.45
setMethod · 0.45
writeFileMethod · 0.45

Tested by

no test coverage detected