-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.js
51 lines (46 loc) · 992 Bytes
/
run.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
var fs = require('fs'),
papa = require('papaparse');
function mapIssues(results) {
var issues = results.map(x => {
return {
fields: {
project: {
key: 'BMO00023'
},
summary: `${x['Defect ID']} ${x.Title}`,
description: x['Symptom (Problem Description)'],
issuetype: {
name: 'Bug'
},
reporter: {
name: 'tmikos'
},
priority: {
name: `Priority ${x.Severity[0]}`
},
assignee: {
name: 'tmikos'
},
customfield_10002: 4
}
}
});
return issues;
}
function callback(err, data) {
if (err) throw err;
console.log(data);
papa.parse(data, {
delimiter: ";",
complete: function (results) {
console.log(results);
var issuesToCreate = mapIssues(results.data);
issuesToCreate.forEach(function(issue) {
var cissue = require('./create.js');
cissue.create(issue);
});
},
header: true
});
}
fs.readFile('defects.csv', 'utf8', callback);