-
Notifications
You must be signed in to change notification settings - Fork 0
/
jira.js
35 lines (30 loc) · 926 Bytes
/
jira.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
const debug = require('debug')('debug');
const fs = require('fs');
const JiraClient = require('jira-connector');
function requireJson(filePath) {
return JSON.parse(fs.readFileSync(filePath));
}
function createClient(configFile) {
return new JiraClient(requireJson(configFile));
}
function getIssue(client, key) {
return client.issue.getIssue({issueKey: key})
.then(issue => Promise.resolve({key:key, issue:issue}))
.catch(error => {
debug(error);
return Promise.resolve({key:key, issue:null});
});
}
function editIssue(client, key, issue) {
return client.issue.editIssue({issueKey: key, issue: issue})
.then(() => Promise.resolve(true))
.catch(error => {
debug(error);
return Promise.resolve(false);
});
}
module.exports = {
createClient: createClient,
getIssue: getIssue,
editIssue: editIssue
}