Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async hashObject(stats: Stats, path: string) {
const stream = new PassThrough()
const output = hasha.fromStream(stream, { algorithm: "sha1" })
stream.push(`blob ${stats.size}\0`)
if (stats.isSymbolicLink()) {
// For symlinks, we follow git's behavior, which is to hash the link itself (i.e. the path it contains) as
// opposed to the file/directory that it points to.
stream.push(await readlink(path))
stream.end()
} else {
createReadStream(path).pipe(stream)
}
return output
}