forked from EreckGordon/angular-universal-pwa-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy-to-github.js
49 lines (39 loc) · 1.21 KB
/
deploy-to-github.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
const path = require('path');
const os = require('os');
const util = require('util');
const exec = util.promisify(require('child_process').exec);
let pathFolder;
if (os.platform() == 'win32') {
// Windows
pathFolder = __dirname.split('\\');
} else {
// Linux / MacOS
pathFolder = __dirname.split('/');
}
let folderLength = pathFolder.length;
let currentFolder = pathFolder[folderLength - parseInt(1)];
let destDir = path.join('..', currentFolder + '-deploy');
process.chdir(destDir);
async function gitAddAll() {
const { stdout, stderr } = await exec('git add .');
console.log('stdout:', stdout);
console.log('stderr:', stderr);
}
async function gitCommit() {
const currentDate = new Date();
const message = `auto generated commit. current time: ${currentDate}.`;
const { stdout, stderr } = await exec(`git commit -m \"${message}\"`);
console.log('stdout:', stdout);
console.log('stderr:', stderr);
}
async function gitPush() {
const { stdout, stderr } = await exec('git push origin master');
console.log('stdout:', stdout);
console.log('stderr:', stderr);
}
async function runAll() {
await gitAddAll();
await gitCommit();
await gitPush();
}
runAll();