-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.js
52 lines (48 loc) · 1.31 KB
/
Utils.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
const log = require('@connibug/js-logging');
module.exports.HasChanged = (oldDat, newDat) => {
if(oldDat.ref != newDat.ref) {
return "ref";
}
if(oldDat.name != newDat.name) {
return "name";
}
if(oldDat.category != newDat.category) {
return "category";
}
if(oldDat.shu != newDat.shu) {
return "shu";
}
if(oldDat.price != newDat.price) {
return "price";
}
if(oldDat.promo != newDat.promo) {
return "promo";
}
if(oldDat.stock != newDat.stock) {
return "stock";
}
return false;
};
const { exec } = require("child_process");
let alreadUpToDateREGEX = new RegExp('Already.up.to.date');
module.exports.handleCD = () => {
exec("git stash", (error, stdout, stderr) => {
exec("git pull", (error, stdout, stderr) => {
if (error) {
log.error(`error: ${error.message}`);
// As there was an issue restart
process.exit(1);
}
if (stderr) {
log.error(`stderr: ${stderr}`);
}
if(stdout.match(alreadUpToDateREGEX)) {
return;
}
else {
log.log(`stdout: ${stdout}`);
process.exit(1);
}
});
});
}