| 8 | import {copyFile, getPaths, readJSON, writeFile, fileExists} from './utils.js'; |
| 9 | |
| 10 | function serializeHashManifest(entries) { |
| 11 | const lines = []; |
| 12 | lines.push('Manifest-Version: 1.0'); |
| 13 | for (const {archivePath, integrity} of entries) { |
| 14 | lines.push(''); |
| 15 | lines.push(`Name: ${archivePath}`); |
| 16 | |
| 17 | lines.push(`Digest-Algorithms:${integrity.md5 ? ' MD5' : ''}${integrity.sha1 ? ' SHA1' : ''}${integrity.sha256 ? ' SHA256' : ''}`); |
| 18 | if (integrity.md5) { |
| 19 | lines.push(`MD5-Digest: ${integrity.md5}`); |
| 20 | } |
| 21 | if (integrity.sha1) { |
| 22 | lines.push(`SHA1-Digest: ${integrity.sha1}`); |
| 23 | } |
| 24 | if (integrity.sha256) { |
| 25 | lines.push(`SHA256-Digest: ${integrity.sha256}`); |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | lines.push(''); |
| 30 | lines.push(''); |
| 31 | |
| 32 | return lines.join('\n'); |
| 33 | } |
| 34 | |
| 35 | async function enumerateStandardPaths(dir, order) { |
| 36 | const path = `./${dir}`; |