Skip to content

Commit 47ead8e

Browse files
committed
Add JSHint checking.
1 parent c56dd78 commit 47ead8e

File tree

6 files changed

+100
-13
lines changed

6 files changed

+100
-13
lines changed

.jshintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/*

.jshintrc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"predef": [
3+
"console",
4+
"-Promise"
5+
],
6+
"expr": true,
7+
"proto": true,
8+
"strict": true,
9+
"indent": 2,
10+
"camelcase": true,
11+
"node": true,
12+
"browser": false,
13+
"boss": true,
14+
"curly": true,
15+
"latedef": "nofunc",
16+
"debug": false,
17+
"devel": false,
18+
"eqeqeq": true,
19+
"evil": true,
20+
"forin": false,
21+
"immed": false,
22+
"laxbreak": false,
23+
"newcap": true,
24+
"noarg": true,
25+
"noempty": false,
26+
"quotmark": true,
27+
"nonew": false,
28+
"nomen": false,
29+
"onevar": false,
30+
"plusplus": false,
31+
"regexp": false,
32+
"undef": true,
33+
"unused": true,
34+
"sub": true,
35+
"trailing": true,
36+
"white": false,
37+
"eqnull": true,
38+
"esnext": true
39+
}

index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function findPackedTag(gitPath, sha) {
3434
if (fs.existsSync(packedRefsFilePath)) {
3535
var packedRefsFile = fs.readFileSync(packedRefsFilePath, {encoding: 'utf8'});
3636
var tagLine = packedRefsFile.split('\n').filter(function(line) {
37-
return line.indexOf("refs/tags") > -1 && line.indexOf(sha) > -1;
37+
return line.indexOf('refs/tags') > -1 && line.indexOf(sha) > -1;
3838
})[0];
3939

4040
if (tagLine) {
@@ -68,13 +68,12 @@ module.exports = function(gitPath) {
6868
abbreviatedSha: null,
6969
branch: null,
7070
tag: null
71-
}
71+
};
7272

7373
try {
7474
var headFilePath = path.join(gitPath, 'HEAD');
7575

7676
if (fs.existsSync(headFilePath)) {
77-
var branchSHA;
7877
var headFile = fs.readFileSync(headFilePath, {encoding: 'utf8'});
7978
var branchName = headFile.split('/').slice(-1)[0].trim();
8079
var refPath = headFile.split(' ')[1];

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
},
2121
"homepage": "https://github.com/rwjblue/git-repo-info",
2222
"devDependencies": {
23-
"mocha": "^1.21.4"
23+
"mocha": "^1.21.4",
24+
"mocha-jshint": "^1.1.0"
2425
}
2526
}

tests/.jshintrc

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"predef": [
3+
"console",
4+
"it",
5+
"describe",
6+
"beforeEach",
7+
"afterEach",
8+
"before",
9+
"after",
10+
"-Promise"
11+
],
12+
"expr": true,
13+
"proto": true,
14+
"strict": true,
15+
"indent": 2,
16+
"camelcase": true,
17+
"node": true,
18+
"browser": false,
19+
"boss": true,
20+
"curly": true,
21+
"latedef": "nofunc",
22+
"debug": false,
23+
"devel": false,
24+
"eqeqeq": true,
25+
"evil": true,
26+
"forin": false,
27+
"immed": false,
28+
"laxbreak": false,
29+
"newcap": true,
30+
"noarg": true,
31+
"noempty": false,
32+
"quotmark": true,
33+
"nonew": false,
34+
"nomen": false,
35+
"onevar": false,
36+
"plusplus": false,
37+
"regexp": false,
38+
"undef": true,
39+
"unused": true,
40+
"sub": true,
41+
"trailing": true,
42+
"white": false,
43+
"eqnull": true,
44+
"esnext": true
45+
}

tests/index.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ var assert = require('assert');
44
var path = require('path');
55
var repoInfo = require('../index');
66

7+
require('mocha-jshint')();
8+
79
var root = process.cwd();
810
var testFixturesPath = path.join(__dirname, 'fixtures');
911
var gitDir = 'dot-git';
@@ -15,7 +17,7 @@ describe('git-repo-info', function() {
1517

1618
afterEach(function() {
1719
process.chdir(root);
18-
})
20+
});
1921

2022
describe('repo lookup', function() {
2123
var repoRoot = path.join(testFixturesPath, 'nested-repo');
@@ -52,57 +54,57 @@ describe('git-repo-info', function() {
5254
describe('repoInfo', function() {
5355
it('returns an object with repo info', function() {
5456
var repoRoot = path.join(testFixturesPath, 'nested-repo');
55-
var result = repoInfo(path.join(repoRoot, gitDir))
57+
var result = repoInfo(path.join(repoRoot, gitDir));
5658

5759
var expected = {
5860
branch: 'master',
5961
sha: '5359aabd3872d9ffd160712e9615c5592dfe6745',
6062
abbreviatedSha: '5359aabd38',
6163
tag: null
62-
}
64+
};
6365

6466
assert.deepEqual(result, expected);
6567
});
6668

6769
it('returns an object with repo info', function() {
6870
var repoRoot = path.join(testFixturesPath, 'detached-head');
69-
var result = repoInfo(path.join(repoRoot, gitDir))
71+
var result = repoInfo(path.join(repoRoot, gitDir));
7072

7173
var expected = {
7274
branch: null,
7375
sha: '9dac893d5a83c02344d91e79dad8904889aeacb1',
7476
abbreviatedSha: '9dac893d5a',
7577
tag: null
76-
}
78+
};
7779

7880
assert.deepEqual(result, expected);
7981
});
8082

8183

8284
it('returns an object with repo info, including the tag (packed tags)', function() {
8385
var repoRoot = path.join(testFixturesPath, 'tagged-commit-packed');
84-
var result = repoInfo(path.join(repoRoot, gitDir))
86+
var result = repoInfo(path.join(repoRoot, gitDir));
8587

8688
var expected = {
8789
branch: 'master',
8890
sha: '5359aabd3872d9ffd160712e9615c5592dfe6745',
8991
abbreviatedSha: '5359aabd38',
9092
tag: 'my-tag'
91-
}
93+
};
9294

9395
assert.deepEqual(result, expected);
9496
});
9597

9698
it('returns an object with repo info, including the tag (unpacked tags)', function() {
9799
var repoRoot = path.join(testFixturesPath, 'tagged-commit-unpacked');
98-
var result = repoInfo(path.join(repoRoot, gitDir))
100+
var result = repoInfo(path.join(repoRoot, gitDir));
99101

100102
var expected = {
101103
branch: 'master',
102104
sha: '5359aabd3872d9ffd160712e9615c5592dfe6745',
103105
abbreviatedSha: '5359aabd38',
104106
tag: 'my-tag'
105-
}
107+
};
106108

107109
assert.deepEqual(result, expected);
108110
});

0 commit comments

Comments
 (0)