-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathversion.js
23 lines (21 loc) · 857 Bytes
/
version.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const fs = require('fs');
const scriptRE = /<script type="text\/javascript" src="https:\/\/cdnjs\.cloudflare\.com\/ajax\/libs\/js-skeleton\/(\d\.\d\.\d)*\/skeleton\.js"><\/script>/gim;
const titleRE = /Skeleton JavaScript library v(\d\.\d\.\d)*/gm;
const { version } = require('./package.json');
const files = [
'./skeleton.js',
'./examples/humanbones/index.html',
'./examples/microblog/index.html',
'./examples/TodoMVC/public/index.html',
'./examples/TodoMVC/public/AllScriptsTogether.html'
]
const setVersion = () => {
files.forEach(file => {
let content = fs.readFileSync(file, 'utf-8');
let reWrittenContent = content
.replace(scriptRE, (str, match) => str.replace(match, version))
.replace(titleRE, (str, match) => str.replace(match, version));
fs.writeFileSync(file, reWrittenContent, 'utf-8');
});
}
module.exports = setVersion;