Skip to content

Commit bd4f4a7

Browse files
committed
1.2.3
- replaces openbadge with badgeit - removes commander and makes arg parser more efficient
1 parent aeb17fe commit bd4f4a7

File tree

5 files changed

+102
-47
lines changed

5 files changed

+102
-47
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 1.2.3 (12/07/2017)
2+
3+
- replaces `openbadge` with `badgeit`
4+
- removes commander and makes arg parser more efficient
5+
- updates dependencies
6+
17
# 1.2.2 (10/29/2017)
28

39
- fixes a bug where coverage.get would kill the entire server

README.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,18 @@ npm install lcov-server -g
4242
```
4343
Usage: lcov-server [options]
4444
45+
Commands:
46+
47+
upload, --upload, -u [server ] Set the url to upload lcov data too (default: http://localhost:8080)
48+
serve, -s, --serve Pass this option to startup a lcov-server instance
49+
version, -v, --version output the version number
50+
help, -h, --help output usage information
4551
4652
Options:
4753
48-
-V, --version output the version number
49-
-u, --upload [server] Set the url to upload lcov data too
50-
-s, --serve Pass this option to startup a lcov-server instance
51-
-d, --db [db] Set the db connection
52-
-p, --parser <parser> Set the parser value [lcov, cobertura, golang, jacoco], defaults to lcov
53-
-bp, --basePath <path> The path that defines the base directory where the files that were covered will be located
54-
-h, --help output usage information
54+
db, -d, --db [db] Set the db connection (default: mongodb://localhost:32768/lcov-server)
55+
parser, -p, --parser <parser> Set the parser value [lcov, cobertura, golang, jacoco], defaults to lcov (default: lcov)
56+
basePath, -bp, --basePath <path> The path that defines the base directory where the files that were covered will be located
5557
```
5658

5759
## Upload

bin/lcov-server.js

+64-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
require('babel-polyfill');
44

5-
const program = require('commander');
65
const updateNotifier = require('update-notifier');
76

87
const cli = require('../lib/cli');
@@ -11,21 +10,73 @@ const pkg = require('../package.json');
1110

1211
updateNotifier({pkg}).notify();
1312

14-
program
15-
.version(pkg.version)
16-
.option('-u, --upload [server]', 'Set the url to upload lcov data too', 'http://localhost:8080')
17-
.option('-s, --serve', 'Pass this option to startup a lcov-server instance')
18-
.option('-d, --db [db]', 'Set the db connection', 'mongodb://localhost:32768/lcov-server')
19-
.option('-p, --parser <parser>', 'Set the parser value [lcov, cobertura, golang, jacoco], defaults to lcov', 'lcov')
20-
.option('-bp, --basePath <path>', 'The path that defines the base directory where the files that were covered will be located')
21-
.parse(process.argv);
13+
const args = process.argv.slice(2);
14+
15+
let program = {};
16+
17+
args.forEach((a, i) => {
18+
switch(a) {
19+
case '-v':
20+
case '--version':
21+
console.log(`v${require('../package.json').version}`); // eslint-disable-line
22+
process.exit(0);
23+
break;
24+
case 'help':
25+
case '-h':
26+
case '--help':
27+
console.log(``+ // eslint-disable-line
28+
`
29+
Usage: lcov-server [options]
30+
31+
Commands:
32+
33+
upload, --upload, -u [server ] Set the url to upload lcov data too (default: http://localhost:8080)
34+
serve, -s, --serve Pass this option to startup a lcov-server instance
35+
version, -v, --version output the version number
36+
help, -h, --help output usage information
37+
38+
Options:
39+
40+
db, -d, --db [db] Set the db connection (default: mongodb://localhost:32768/lcov-server)
41+
parser, -p, --parser <parser> Set the parser value [lcov, cobertura, golang, jacoco], defaults to lcov (default: lcov)
42+
basePath, -bp, --basePath <path> The path that defines the base directory where the files that were covered will be located
43+
`);
44+
process.exit(0);
45+
break;
46+
case '-db':
47+
case '--db':
48+
case 'db':
49+
program.db = args[i + 1];
50+
break;
51+
case '-u':
52+
case '--upload':
53+
case 'upload':
54+
program.upload = args[i + 1];
55+
break;
56+
case '-s':
57+
case '--serve':
58+
case 'serve':
59+
program.serve = true;
60+
break;
61+
case '-p':
62+
case '--parser':
63+
case 'parser':
64+
program.parser = args[i + 1];
65+
if(['lcov', 'cobertura', 'golang', 'jacoco'].indexOf(program.parser) === -1) {
66+
console.error(`parser ${program.parser} not supported`); // eslint-disable-line
67+
process.exit(1);
68+
}
69+
break;
70+
case '-bp':
71+
case '--basePath':
72+
case 'basePath':
73+
program.basePath = args[i + 1];
74+
break;
75+
}
76+
});
2277

2378
const { parser, upload, serve, db, basePath } = program;
2479

25-
if(parser && ['lcov', 'cobertura', 'golang', 'jacoco'].indexOf(parser) === -1) {
26-
console.error(`parser ${parser} not supported`); // eslint-disable-line
27-
process.exit(1);
28-
}
2980

3081
if(serve) {
3182
process.env.MONGO_URL = process.env.MONGO_URL || db;

index.js

+7-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ mongoose.connect(process.env.MONGO_URL, { useMongoClient: true }, function(error
99
});
1010

1111
const express = require('express');
12-
const Badge = require('openbadge');
12+
const Badge = require('badgeit');
1313
const parse = require('git-url-parse');
1414
const path = require('path');
1515
const serveStatic = require('serve-static');
@@ -123,17 +123,13 @@ app.get('/badge/:service/:owner/:repo.svg', asyncMiddleware(async (req, res) =>
123123
const percentage = parseInt((hit / found) * 100);
124124
const color = percentage >= 85 ? '#3DB712' : percentage <= 85 && percentage >= 70 ? '#caa300' : '#cc5338';
125125

126-
Badge({ color: { right: color }, text: ['coverage', `${percentage}%`] }, function(err, badge) {
127-
if(err) { throw new Error(err); }
128-
res.set('Content-Type', 'image/svg+xml; charset=utf-8');
129-
res.send(badge);
130-
});
126+
const badge = await Badge({ color: { right: color }, text: ['coverage', `${percentage}%`] });
127+
res.set('Content-Type', 'image/svg+xml; charset=utf-8');
128+
res.send(badge);
131129
} catch(error) {
132-
Badge({ color: { right: "#b63b3b" }, text: ['coverage', 'not found'] }, function(err, badge) {
133-
if(err) { throw new Error(err); }
134-
res.set('Content-Type', 'image/svg+xml; charset=utf-8');
135-
res.send(badge);
136-
});
130+
const badge = await Badge({ color: { right: "#b63b3b" }, text: ['coverage', 'not found'] });
131+
res.set('Content-Type', 'image/svg+xml; charset=utf-8');
132+
res.send(badge);
137133
}
138134
}));
139135

package.json

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lcov-server",
3-
"version": "1.2.2",
3+
"version": "1.2.3",
44
"description": "🎯 A simple lcov server & cli parser",
55
"main": "index.js",
66
"homepage": "https://github.com/gabrielcsapo/lcov-server#readme",
@@ -52,20 +52,20 @@
5252
"license": "Apache-2.0",
5353
"dependencies": {
5454
"babel-polyfill": "^6.26.0",
55-
"commander": "^2.11.0",
55+
"badgeit": "0.0.2",
5656
"compression": "^1.7.1",
5757
"express": "^4.16.2",
5858
"git-url-parse": "^7.0.1",
59-
"mongoose": "^4.12.4",
60-
"moment": "^2.19.1",
59+
"moment": "^2.19.3",
60+
"mongoose": "^4.13.6",
6161
"openbadge": "^1.0.4",
6262
"serve-static": "^1.13.1",
6363
"update-notifier": "^2.3.0",
6464
"xml2js": "^0.4.19"
6565
},
6666
"devDependencies": {
67-
"@storybook/addon-knobs": "^3.2.13",
68-
"@storybook/react": "^3.2.13",
67+
"@storybook/addon-knobs": "^3.2.17",
68+
"@storybook/react": "^3.2.17",
6969
"babel-cli": "^6.26.0",
7070
"babel-core": "^6.26.0",
7171
"babel-loader": "^7.1.2",
@@ -75,25 +75,25 @@
7575
"body-parser": "^1.18.2",
7676
"css-loader": "^0.28.7",
7777
"docdash": "^0.4.0",
78-
"eslint": "^4.10.0",
79-
"eslint-plugin-react": "^7.4.0",
78+
"eslint": "^4.12.1",
79+
"eslint-plugin-react": "^7.5.1",
8080
"getstorybook": "^1.7.0",
8181
"highlight.js": "^9.12.0",
8282
"jsdoc": "^3.5.4",
83-
"pkg": "^4.2.5",
83+
"pkg": "^4.2.6",
8484
"prop-types": "^15.6.0",
8585
"psychic.css": "0.0.1",
86-
"react": "^16.0.0",
87-
"react-dom": "^16.0.0",
86+
"react": "^16.2.0",
87+
"react-dom": "^16.2.0",
8888
"react-router-dom": "^4.2.2",
89-
"react-select": "^1.0.0-rc.10",
89+
"react-select": "^1.1.0",
9090
"shelljs": "^0.7.8",
9191
"style-loader": "^0.19.0",
92-
"tap": "^10.7.2",
92+
"tap": "^11.0.0",
9393
"tape": "^4.8.0",
94-
"tryitout": "^0.3.7",
95-
"webpack": "^3.8.1",
96-
"webpack-dev-server": "^2.9.3",
94+
"tryitout": "^1.2.0",
95+
"webpack": "^3.10.0",
96+
"webpack-dev-server": "^2.9.7",
9797
"whatwg-fetch": "^2.0.3"
9898
}
9999
}

0 commit comments

Comments
 (0)