mihomo-party/scripts/checksum.mjs

14 lines
434 B
JavaScript
Raw Permalink Normal View History

2024-08-23 14:05:13 +08:00
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)
}
}
}