forked from googleads/videojs-ima
-
Notifications
You must be signed in to change notification settings - Fork 0
/
postversion.js
76 lines (70 loc) · 2.46 KB
/
postversion.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const execSync = require('child_process').execSync;
const path = require('path');
const pkg = require('../package.json');
const rimraf = require('rimraf');
process.chdir(path.resolve(__dirname, '..'));
// Push master.
// Check out gh-pages.
// Merge master.
// npm install.
const preNpmInstallCommands = [
'git push origin master',
'git push --tags',
'git branch -D gh-pages',
'git checkout -b gh-pages origin/gh-pages',
'git merge -X theirs master -m "Syncing gh-pages to master v' + pkg.version + '"'
];
console.log('Executing pre npm install commands');
try {
var cmdOut = execSync(preNpmInstallCommands.join(' && '));
console.log('Executd pre npm install commands', cmdOut);
} catch (error) {
console.log('Error running pre npm install commands:', error.error);
}
// Remove the node_modules directory on gh-pages.
console.log('Removing old node_modules on gh-pages.');
rimraf.sync('node_modules');
console.log('Removed old node_modules on gh-pages.');
// Install node modules.
// Build latest.
// Add modified files (examples, dist, and node_modules).
// Commit and push to gh-pages
// Switch back to master.
const postNpmInstallCommands = [
'npm install',
'npm run rollup',
'git add --all',
'git add -f dist/',
'git add -f node_modules/video.js/dist/video-js.min.css',
'git add -f node_modules/video.js/dist/video.min.js',
'git add -f node_modules/videojs-contrib-ads/dist/videojs.ads.css',
'git add -f node_modules/videojs-contrib-ads/dist/videojs.ads.min.js',
'git add -f node_modules/can-autoplay/build/can-autoplay.min.js',
'git commit -m "Build for samples at v' + pkg.version + '"',
'git push -f origin gh-pages',
'git checkout master'
];
console.log('Running install and pushing new gh-pages.');
try {
var cmdOut = execSync(postNpmInstallCommands.join(' && '));
console.log('Ran install and pushed new gh-pages', cmdOut);
} catch (error) {
console.log('Error runninng install and pushing new gh-pages:', error.error);
}
// Remove the node_modules directory on master.
console.log('Removing old node_modules on master.');
rimraf.sync('node_modules');
console.log('Removed old node_modules on master.');
// Install node modules.
// Build latest.
const backOnMasterCommands = [
'npm install',
'npm run rollup'
];
console.log('Running build on master.');
try {
var cmdOut = execSync(backOnMasterCommands.join(' && '));
console.log('Ran build on master', cmdOut);
} catch (error) {
console.log('Error runninng build on master:', error.error);
}