forked from vuejs/v2.vuejs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.js
31 lines (27 loc) · 821 Bytes
/
update.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
var fs = require('fs')
var version = require('../vue/package.json').version
var themeconfPath = 'themes/vue/_config.yml'
var installPath = 'source/guide/installation.md'
var themeconfig = fs.readFileSync(themeconfPath, 'utf-8')
var installation = fs.readFileSync(installPath, 'utf-8')
fs.writeFileSync(
themeconfPath,
themeconfig.replace(/vue_version: .*/, 'vue_version: ' + version)
)
var sizes = {
dev: 'vue.js',
min: 'vue.min.js',
gz: 'vue.min.js.gz'
}
for (var file in sizes) {
var filesize = fs.statSync('../vue/dist/' + sizes[file], 'utf-8').size
sizes[file] = (filesize / 1024).toFixed(2)
}
fs.writeFileSync(
installPath,
installation
.replace(/vue_version: .*/, 'vue_version: ' + version)
.replace(/(\w+)_size:.*/g, function (m, p1) {
return p1 + '_size: ' + sizes[p1]
})
)