-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.js
62 lines (44 loc) · 1.94 KB
/
deploy.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
require('shelljs/global');
var moment = require('moment');
moment.locale('ru');
config.silent = true
console.time("Время выполнения");
// rm('-r', 'static');
rm('-r', 'staticDecor/dist');
exec('buster generate', function() {
console.log("Сгенерирована копия Ghost сайта");
console.log("Запуск оптимизации");
console.log("...");
exec('cd staticDecor && grunt', function() {
console.log("Оптимизированно");
console.timeEnd("Время выполнения");
console.log("Подготовка перед отправкой");
cp('-Rf', 'staticDecor/dist/', 'staticGit');
console.log("Скопированно...");
// Работа с git
var emoji = [':ghost:', ':sunglasses:', ':boom:', ':skull:', ':speech_balloon:',
':rage3:', ':waning_gibbous_moon:', ':tada:', ':pushpin:', ':wink:', ':hankey:'
]
var commitMesg = rand(emoji) + " Обновление блога от: " + moment().format("LL") + rand(emoji);
exec('git add . && git commit -m"' + commitMesg + '" && git push', function(code, output) {
if (!code) {
console.log("Всё готово");
} else {
console.log(output);
}
console.log("Отправка основного репозитория закончена");
console.log("Отправка статического блога");
exec('cd staticGit && git add . && git commit -m"' + commitMesg + '" && git push', function(code, output) {
if (!code) {
console.log("Всё готово");
} else {
console.log('Program output:', output);
}
});
})
});
});
function rand(arr) {
var rand = Math.floor(Math.random() * arr.length);
return arr[rand];
}