本文整理汇总了TypeScript中builder-util.hashFile函数的典型用法代码示例。如果您正苦于以下问题:TypeScript hashFile函数的具体用法?TypeScript hashFile怎么用?TypeScript hashFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hashFile函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createUpdateInfo
async function createUpdateInfo(version: string, event: ArtifactCreated, releaseInfo: ReleaseInfo) {
const info: UpdateInfo = {
version,
releaseDate: new Date().toISOString(),
path: path.basename(event.file!),
sha512: await hashFile(event.file!),
...releaseInfo as UpdateInfo,
}
const packageFiles = event.packageFiles
if (packageFiles != null) {
const keys = Object.keys(packageFiles)
if (keys.length > 0) {
info.packages = {}
for (const arch of keys) {
const packageFileInfo = packageFiles[arch]
info.packages[arch] = {
...packageFileInfo,
file: path.basename(packageFileInfo.file)
}
}
}
}
return info
}
示例2: hashFile
const sha2 = new Lazy<string>(() => hashFile(event.file!, "sha256", "hex"))
示例3: createUpdateInfo
async function createUpdateInfo(version: string, event: ArtifactCreated, releaseInfo: ReleaseInfo): Promise<UpdateInfo> {
const customUpdateInfo = event.updateInfo
const url = path.basename(event.file!)
const sha512 = (customUpdateInfo == null ? null : customUpdateInfo.sha512) || await hashFile(event.file!)
const files = [{url, sha512}]
const result: UpdateInfo = {
version,
files,
path: url /* backward compatibility, electron-updater 1.x - electron-updater 2.15.0 */,
sha512 /* backward compatibility, electron-updater 1.x - electron-updater 2.15.0 */,
...releaseInfo as UpdateInfo,
}
if (customUpdateInfo != null) {
// file info or nsis web installer packages info
Object.assign("sha512" in customUpdateInfo ? files[0] : result, customUpdateInfo)
}
return result
}