-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #352 from mvdicarlo/develop
v3.1.46
- Loading branch information
Showing
6 changed files
with
115 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const crypto = require('crypto'); | ||
const { version } = require('./package.json'); | ||
const { parse, stringify } = require('yaml'); | ||
|
||
const BASE_PATH = path.join(__dirname, 'release'); | ||
const SETUP_PATH = path.join(BASE_PATH, `postybirb-plus-setup-${version}.exe`); | ||
const YAML_PATH = path.join(BASE_PATH, `latest.yml`); | ||
|
||
function hashFile(file, algorithm = 'sha512', encoding = 'base64', options) { | ||
return new Promise((resolve, reject) => { | ||
const hash = crypto.createHash(algorithm); | ||
hash.on('error', reject).setEncoding(encoding); | ||
fs.createReadStream( | ||
file, | ||
Object.assign({}, options, { | ||
highWaterMark: 1024 * 1024, | ||
/* better to use more memory but hash faster */ | ||
}), | ||
) | ||
.on('error', reject) | ||
.on('end', () => { | ||
hash.end(); | ||
resolve(hash.read()); | ||
}) | ||
.pipe(hash, { | ||
end: false, | ||
}); | ||
}); | ||
} | ||
|
||
hashFile(SETUP_PATH).then(hash => { | ||
console.log(hash); | ||
const yaml = parse(fs.readFileSync(YAML_PATH, 'utf8')); | ||
yaml.sha512 = hash; | ||
yaml.files[0].sha512 = hash; | ||
console.log(stringify(yaml)); | ||
fs.writeFileSync(YAML_PATH, stringify(yaml)); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.