This repository has been archived by the owner on Apr 11, 2018. It is now read-only.
forked from angular/material
-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateVersionPicker.js
60 lines (54 loc) · 1.74 KB
/
updateVersionPicker.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
(function () {
'use strict';
const child_process = require('child_process');
const defaultOptions = { encoding: 'utf-8' };
exec([
'git checkout master',
'rm -rf /tmp/ngcode',
'git clone https://github.com/angular/code.material.angularjs.org.git --depth=1 /tmp/ngcode'
]);
const docs = require('/tmp/ngcode/docs.json');
docs.versions.forEach(function (version) {
exec([
'rm -rf dist',
'git checkout v' + version,
'npm install',
checkout('app/js/app.js'),
checkout('app/css/style.css'),
checkout('app/img/icons'),
checkout('app/partials'),
checkout('config/template/index.template.html'),
'gulp docs --release',
'cp -r dist/docs/docs.js /tmp/ngcode/' + version,
'cp -r dist/docs/docs.css /tmp/ngcode/' + version,
'cp -r dist/docs/index.html /tmp/ngcode/' + version,
'cp -r dist/docs/img/icons/* /tmp/ngcode/' + version + '/img/icons',
'git checkout master'
]);
function checkout (filename) {
return 'git checkout origin/master -- docs/' + filename;
}
});
exec([
'ls',
'rm -rf latest',
`cp -r ${docs.latest} latest`,
'git add -A',
'git commit -m "updating version picker for old releases"',
'git push'
], { cwd: '/tmp/ngcode' });
//-- utility methods
function exec (cmd, userOptions) {
if (cmd instanceof Array) {
return cmd.map(function (cmd) { return exec(cmd, userOptions); });
}
try {
const options = Object.create(defaultOptions);
for (const key in userOptions) options[key] = userOptions[key];
console.log(`\n--------\n ${cmd}`);
return console.log(child_process.execSync(cmd, options).trim());
} catch (err) {
return err;
}
}
})();