Skip to content

Commit de0e781

Browse files
committed
Fix issues with csv output
1 parent e3ddf8c commit de0e781

File tree

5 files changed

+45
-12
lines changed

5 files changed

+45
-12
lines changed

gtt-report.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ new Promise(resolve => {
177177
// make report
178178
.then(() => new Promise(resolve => {
179179
if (report.issues.length === 0 && report.mergeRequests.length === 0) Cli.error('No issues or merge requests matched your criteria.');
180-
181180
Cli.list(`${Cli.output} Making report`);
182181

183182
output = new Output[config.get('output')](config, report);

gtt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22

3-
const version = '1.0.2';
3+
const version = '1.0.3';
44
const program = require('commander');
55

66
program

include/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class cli {
8585
* @param message
8686
*/
8787
static warn(message) {
88-
cli.out(` Warning: ${message} `.bgWhite.black);
88+
cli.out(` Warning: ${message} `.bgWhite.black + "\n");
8989
}
9090

9191
/**

output/csv.js

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
const _ = require('underscore');
2+
const fs = require('fs');
3+
const path = require('path');
24
const Csv = require('csv-string');
35

46
const Base = require('./base');
@@ -43,15 +45,47 @@ class csv extends Base {
4345
this.csvRecords = Csv.stringify(times);
4446
}
4547

48+
toFile(file) {
49+
let fileName = path.basename(file);
50+
let extName = path.extname(file);
51+
52+
if (this.config.get('report').includes('stats')) {
53+
fs.writeFileSync(file.replace(fileName, fileName.replace(extName, `.stats${extName}`)), this.csvStats);
54+
}
55+
56+
if (this.config.get('report').includes('issues')) {
57+
fs.writeFileSync(file.replace(fileName, fileName.replace(extName, `.issues${extName}`)), this.csvIssues);
58+
}
59+
60+
if (this.config.get('report').includes('merge_requests')) {
61+
fs.writeFileSync(file.replace(fileName, fileName.replace(extName, `.mergeRequests${extName}`)), this.csvMergeRequests);
62+
}
63+
64+
if (this.config.get('report').includes('records')) {
65+
fs.writeFileSync(file.replace(fileName, fileName.replace(extName, `.records${extName}`)), this.csvRecords);
66+
}
67+
}
68+
4669
toStdOut() {
47-
this.headline('STATS');
48-
this.write(this.csvStats);
49-
this.headline('ISSUES');
50-
this.write(this.csvIssues);
51-
this.headline('MERGE REQUESTS');
52-
this.write(this.csvMergeRequests);
53-
this.headline('TIME RECORDS');
54-
this.write(this.csvRecords);
70+
if (this.config.get('report').includes('state')) {
71+
this.headline('STATS');
72+
this.write(this.csvStats);
73+
}
74+
75+
if (this.config.get('report').includes('issues')) {
76+
this.headline('ISSUES');
77+
this.write(this.csvIssues);
78+
}
79+
80+
if (this.config.get('report').includes('merge_requests')) {
81+
this.headline('MERGE REQUESTS');
82+
this.write(this.csvMergeRequests);
83+
}
84+
85+
if (this.config.get('report').includes('records')) {
86+
this.headline('TIME RECORDS');
87+
this.write(this.csvRecords);
88+
}
5589

5690
super.toStdOut();
5791
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gitlab-time-tracker",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "A CLI that makes working with GitLabs time tracking feature more enjoyable",
55
"main": "gtt.js",
66
"scripts": {},

0 commit comments

Comments
 (0)