* @private * @type {Processor<string, ContextHash>}
(path, callback)
| 4056 | * @type {Processor<string, ContextHash>} |
| 4057 | */ |
| 4058 | _readContextHash(path, callback) { |
| 4059 | this._readContext( |
| 4060 | { |
| 4061 | path, |
| 4062 | fromImmutablePath: () => /** @type {ContextHash | ""} */ (""), |
| 4063 | fromManagedItem: (info) => info || "", |
| 4064 | fromSymlink: (file, target, callback) => { |
| 4065 | callback( |
| 4066 | null, |
| 4067 | /** @type {ContextHash} */ |
| 4068 | ({ |
| 4069 | hash: target, |
| 4070 | symlinks: new Set([target]) |
| 4071 | }) |
| 4072 | ); |
| 4073 | }, |
| 4074 | fromFile: (file, stat, callback) => |
| 4075 | this.getFileHash(file, (err, hash) => { |
| 4076 | callback(err, hash || ""); |
| 4077 | }), |
| 4078 | fromDirectory: (directory, stat, callback) => { |
| 4079 | this.contextHashQueue.increaseParallelism(); |
| 4080 | this._getUnresolvedContextHash(directory, (err, hash) => { |
| 4081 | this.contextHashQueue.decreaseParallelism(); |
| 4082 | callback(err, hash || ""); |
| 4083 | }); |
| 4084 | }, |
| 4085 | /** |
| 4086 | * Returns reduced hash. |
| 4087 | * @param {string[]} files files |
| 4088 | * @param {(string | ContextHash)[]} fileHashes hashes |
| 4089 | * @returns {ContextHash} reduced hash |
| 4090 | */ |
| 4091 | reduce: (files, fileHashes) => { |
| 4092 | /** @type {undefined | Symlinks} */ |
| 4093 | let symlinks; |
| 4094 | const hash = createHash(this._hashFunction); |
| 4095 | |
| 4096 | for (const file of files) hash.update(file); |
| 4097 | for (const entry of fileHashes) { |
| 4098 | if (typeof entry === "string") { |
| 4099 | hash.update(entry); |
| 4100 | } else { |
| 4101 | hash.update(entry.hash); |
| 4102 | if (entry.symlinks) { |
| 4103 | if (symlinks === undefined) symlinks = new Set(); |
| 4104 | addAll(entry.symlinks, symlinks); |
| 4105 | } |
| 4106 | } |
| 4107 | } |
| 4108 | |
| 4109 | /** @type {ContextHash} */ |
| 4110 | const result = { |
| 4111 | hash: hash.digest("hex") |
| 4112 | }; |
| 4113 | if (symlinks) result.symlinks = symlinks; |
| 4114 | return result; |
| 4115 | } |
nothing calls this directly
no test coverage detected