mirror of
https://github.com/twitter/twemoji.git
synced 2024-06-15 03:35:16 +00:00
Write the current version into the script tags when generating
This commit is contained in:
parent
252a288f16
commit
36a6083dcc
@ -56,14 +56,17 @@ const digest = spawnSync('openssl', ['dgst', `-${algorithm}`, '-binary', file('t
|
||||
if (digest.status || digest.signal){
|
||||
throw new Error(digest.stderr.toString('utf8'));
|
||||
}
|
||||
const integrity = `integrity="${algorithm}-${digest.stdout.toString('base64')}"`;
|
||||
const integrityHash = digest.stdout.toString('base64');
|
||||
const integrity = ``;
|
||||
const { version } = require('../../package.json');
|
||||
const src = ``
|
||||
|
||||
function updateIntegrity(filename) {
|
||||
function updateScript(filename) {
|
||||
const newScript = `<script src="https://twemoji.maxcdn.com/2/twemoji.min.js?${version}" integrity="${algorithm}-${integrityHash}"`
|
||||
fs.writeFileSync(
|
||||
filename,
|
||||
fs.readFileSync(filename).toString('utf8').replace(/integrity="[^ ]*"/, integrity));
|
||||
fs.readFileSync(filename).toString('utf8').replace(/<script src="[^ ]*" integrity="[^ ]*"/, newScript));
|
||||
}
|
||||
|
||||
updateIntegrity(file('..', 'README.md'));
|
||||
updateIntegrity(file('templates', 'preview.html'));
|
||||
|
||||
updateScript(file('..', 'README.md'));
|
||||
updateScript(file('templates', 'preview.html'));
|
||||
|
Loading…
Reference in New Issue
Block a user