mihomo-party/scripts/checksum.mjs
2024-08-23 14:25:09 +08:00

14 lines
434 B
JavaScript

import { readFileSync, readdirSync, writeFileSync } from 'fs'
import { createHash } from 'crypto'
const files = readdirSync('dist')
for (const file of files) {
for (const ext of process.argv.slice(2)) {
if (file.endsWith(ext)) {
const content = readFileSync(`dist/${file}`)
const checksum = createHash('sha256').update(content, 'utf8').digest('hex')
writeFileSync(`dist/${file}.sha256`, checksum)
}
}
}