-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.js
30 lines (22 loc) · 1.05 KB
/
release.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
const fs = require('fs');
const sri = require('sri');
const package = require('./package.json');
const version = package.version;
const dir = `versions/${version}`;
if (!fs.existsSync(dir)){
fs.mkdirSync(dir, {recursive: true});
}
fs.copyFileSync('dist/bundle.js', `${dir}/bundle.js`);
fs.copyFileSync('dist/bundle.css', `${dir}/bundle.css`);
//
// See https://www.srihash.org/ for more info about this section
//
const jsSriHash = sri.getSRIString(fs.readFileSync(`${dir}/bundle.js`).toString());
const cssSriHash = sri.getSRIString(fs.readFileSync(`${dir}/bundle.css`).toString());
const readmeContent = `# Встраивание модуля на страницу
\`\`\`
<script defer src="https://cdn.jsdelivr.net/gh/mr9d/acomics-crop@master/versions/${version}/bundle.js" integrity="${jsSriHash}" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/mr9d/acomics-crop@master/versions/${version}/bundle.css" integrity="${cssSriHash}" crossorigin="anonymous">
\`\`\`
`;
fs.writeFileSync(`${dir}/README.md`, readmeContent);