MCPcopy
hub / github.com/webpack/webpack / processExistingFile

Method processExistingFile

lib/Compiler.js:979–1010  ·  view source on GitHub ↗
(stats)

Source from the content-addressed store, hash-verified

977 * @returns {void}
978 */
979 const processExistingFile = (stats) => {
980 // skip emitting if it's already there and an immutable file
981 if (immutable) {
982 updateWithReplacementSource(/** @type {number} */ (stats.size));
983 return alreadyWritten();
984 }
985
986 const content = getContent();
987
988 updateWithReplacementSource(content.length);
989
990 // if it exists and content on disk matches content
991 // skip writing the same content again
992 // (to keep mtime and don't trigger watchers)
993 // for a fast negative match file size is compared first
994 if (content.length === stats.size) {
995 compilation.comparedForEmitAssets.add(file);
996 return /** @type {OutputFileSystem} */ (
997 this.outputFileSystem
998 ).readFile(targetPath, (err, existingContent) => {
999 if (
1000 err ||
1001 !content.equals(/** @type {Buffer} */ (existingContent))
1002 ) {
1003 return doWrite(content);
1004 }
1005 return alreadyWritten();
1006 });
1007 }
1008
1009 return doWrite(content);
1010 };
1011
1012 const processMissingFile = () => {
1013 const content = getContent();

Callers

nothing calls this directly

Calls 2

readFileMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected