mirror of
https://github.com/gradle/wrapper-validation-action.git
synced 2025-04-16 12:19:18 +08:00
19 lines
492 B
TypeScript
19 lines
492 B
TypeScript
import * as crypto from 'crypto'
|
|
import * as fs from 'fs'
|
|
|
|
export async function sha256File(path: string): Promise<string> {
|
|
return new Promise((resolve, reject) => {
|
|
const hash = crypto.createHash('sha256')
|
|
const stream = fs.createReadStream(path)
|
|
stream.on('data', data => hash.update(data))
|
|
stream.on('end', () => {
|
|
stream.destroy()
|
|
resolve(hash.digest('hex'))
|
|
})
|
|
stream.on('error', error => {
|
|
stream.destroy()
|
|
reject(error)
|
|
})
|
|
})
|
|
}
|