forked from bitshares/bitshares-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
write_digest.js
50 lines (42 loc) · 1.44 KB
/
write_digest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
var crypto = require("crypto");
var fs = require("fs");
var os = require("os");
var path = require("path");
var packageJSON = require("./package.json");
var jetpack = require("fs-jetpack");
var releasesDir = jetpack.dir("./build");
console.log(`\nUI version ${packageJSON.version} sha256 sums:\n`);
var platform = os.platform();
var binaryPath = "build/binaries/";
var htmlPath = "build/";
var files = [];
var binaries = fs.readdirSync(binaryPath).filter(function(a) {
return a.indexOf(packageJSON.version) !== -1;
});
binaries.forEach(function(file) {
files.push({fullPath: path.resolve(binaryPath, file), fileName: file});
});
var htmlZipFiles = fs.readdirSync(htmlPath).filter(function(a) {
return a.indexOf(packageJSON.version) !== -1 && a.indexOf("zip") !== -1;
});
htmlZipFiles.forEach(function(file) {
files.push({fullPath: path.resolve(htmlPath, file), fileName: file});
});
if (!files.length) return;
releasesDir.remove(`release-checksums-${platform}`);
files.forEach(function(file) {
var sha256 = crypto.createHash("sha256");
var s = fs.ReadStream(file.fullPath);
s.on("data", function(d) {
sha256.update(d);
});
s.on("end", function() {
var d2 = sha256.digest("hex");
console.log(`__${file.fileName}__`);
console.log("`" + d2 + "`");
releasesDir.append(
`release-checksums-${platform}`,
`\n__${file.fileName}__` + "\n`" + d2 + "`"
);
});
});