-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost-checkout.sample
More file actions
67 lines (53 loc) · 1.31 KB
/
post-checkout.sample
File metadata and controls
67 lines (53 loc) · 1.31 KB
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
#!/usr/bin/env node
const http = require('http');
const https = require('https');
const util = require('util');
const childProcessExec = require('child_process').exec;
const config = require('../../branches-manager.config.json');
const exec = util.promisify(childProcessExec);
const getBranchName = async () => {
const branches = (await exec('git branch')).stdout;
const current = (
branches
.split('\n')
.find(
(b) => b.trim()[0] === '*',
)
);
return current.substring(2);
};
const execute = async () => {
const branch = await getBranchName();
const postData = JSON.stringify({
server: config.serverName,
branch,
email: config.email,
password: config.password,
});
const protocol = config.useHttps ? https : http;
const port = config.appPort || (config.useHttps ? 443 : 80);
const options = {
hostname: config.appHost,
port,
path: '/api/change-issue',
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
};
const req = protocol.request(options, (res) => {
res.on('data', (data) => {
console.log(`${data}`);
});
res.on('end', () => {
process.exit(0);
});
});
req.on('error', (e) => {
console.error(e);
process.exit(1);
});
req.write(postData);
req.end();
};
execute();