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

Function getWriteFileUpdatingSignatureCallback

test/fixtures/snapshot/typescript.js:120865–120898  ·  view source on GitHub ↗
(writeFile)

Source from the content-addressed store, hash-verified

120863 writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* BuilderFileEmit.DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
120864 }
120865 function getWriteFileUpdatingSignatureCallback(writeFile) {
120866 return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
120867 var _a;
120868 if (ts.isDeclarationFileName(fileName)) {
120869 ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
120870 var file = sourceFiles[0];
120871 var info = state.fileInfos.get(file.resolvedPath);
120872 var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
120873 if (signature === file.version) {
120874 var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
120875 if (newSignature !== file.version) { // Update it
120876 if (host.storeFilesChangingSignatureDuringEmit)
120877 (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
120878 if (state.exportedModulesMap)
120879 ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
120880 if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
120881 state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature);
120882 }
120883 else {
120884 info.signature = newSignature;
120885 if (state.exportedModulesMap)
120886 ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
120887 }
120888 }
120889 }
120890 }
120891 if (writeFile)
120892 writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
120893 else if (host.writeFile)
120894 host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
120895 else
120896 state.program.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
120897 };
120898 }
120899 /**
120900 * Emits the JavaScript and declaration files.
120901 * When targetSource file is specified, emits the files corresponding to that source file,

Callers 2

emitNextAffectedFileFunction · 0.85
emitFunction · 0.85

Calls 6

assertMethod · 0.80
writeFileFunction · 0.70
getMethod · 0.65
addMethod · 0.65
setMethod · 0.45
writeFileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…