Skip to content

Commit dc4e9b1

Browse files
committed
Initial commit
0 parents  commit dc4e9b1

File tree

56 files changed

+4257
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+4257
-0
lines changed

.babelrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"presets": ["env"],
3+
"plugins": [
4+
"add-module-exports"
5+
]
6+
}

.eslintrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "airbnb-base",
3+
"plugins": [
4+
"import"
5+
]
6+
}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
build.js
3+
.nyc_output
4+
npm-debug.log
5+
coverage

.npmignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
node_modules
2+
index.js
3+
.nyc_output
4+
npm-debug.log
5+
coverage
6+
test
7+
test.js
8+
.babelrc
9+
.eslintrc.json
10+
.travis.yml
11+
.appveyor.yml
12+
yarn.lock

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: node_js
2+
sudo: true
3+
dist: trusty
4+
node_js:
5+
- "4"
6+
- "6"
7+
install:
8+
- yarn
9+
notifications:
10+
email:
11+
on_failure: change
12+
on_success: change
13+
after_success:
14+
- npm run coveralls

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Lukas Aichbauer
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 33 additions & 0 deletions

appveyor.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Test against this version of Node.js
2+
environment:
3+
matrix:
4+
# node.js
5+
- nodejs_version: "4"
6+
- nodejs_version: "6"
7+
8+
# Install scripts. (runs after repo cloning)
9+
install:
10+
# Get the latest stable version of Node.js or io.js
11+
- ps: Install-Product node $env:nodejs_version
12+
# install modules
13+
- npm config set loglevel warn
14+
- npm i -g npm
15+
- npm i
16+
17+
# Post-install test scripts.
18+
test_script:
19+
# Output useful info for debugging.
20+
- node --version
21+
- npm --version
22+
# run tests
23+
- npm test
24+
25+
# Don't actually build.
26+
build: off

index.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import execa from 'execa';
2+
import isGit from 'is-git-repository';
3+
import { platform } from 'os';
4+
import makepath from 'path';
5+
import pathIsAbsolute from 'path-is-absolute';
6+
7+
const cwd = process.cwd();
8+
9+
const countGitTags = ({ path, local } = {}) => {
10+
let countOfTags = 0;
11+
12+
let thisPath = path || cwd;
13+
thisPath = pathIsAbsolute(thisPath) ? thisPath : makepath.join(cwd, thisPath);
14+
const thisLocal = local === undefined ? true : local;
15+
16+
if (!isGit(thisPath)) {
17+
return 0;
18+
}
19+
20+
try {
21+
let getTagsExec;
22+
let getTags;
23+
if (thisLocal) {
24+
if (platform() === 'win32') {
25+
getTagsExec = `pushd ${thisPath} & git tag`;
26+
} else {
27+
getTagsExec = `(cd ${thisPath} ; git tag)`;
28+
}
29+
30+
getTags = execa.shellSync(getTagsExec).stdout;
31+
} else {
32+
if (platform() === 'win32') {
33+
getTagsExec = `pushd ${thisPath} & git ls-remote --tags`;
34+
} else {
35+
getTagsExec = `(cd ${thisPath} ; git ls-remote --tags)`;
36+
}
37+
38+
getTags = execa.shellSync(getTagsExec).stdout;
39+
}
40+
41+
countOfTags = getTags.length === 0 ? getTags.length : getTags.split('\n').length;
42+
43+
return countOfTags;
44+
} catch (e) {
45+
return 0;
46+
}
47+
};
48+
49+
export default countGitTags;

package.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"name": "count-git-tags",
3+
"version": "0.0.0",
4+
"description": "A tool to count the number of tags of a git repository",
5+
"main": "build.js",
6+
"scripts": {
7+
"pretest": "npm run lint",
8+
"test": "nyc ava",
9+
"lint": "eslint index.js",
10+
"coveralls": "nyc report --reporter=text-lcov | coveralls",
11+
"prepublish": "npm run babel",
12+
"babel": "babel index.js -o build.js"
13+
},
14+
"repository": {
15+
"type": "git",
16+
"url": "git+https://github.com/aichbauer/node-count-git-tags.git"
17+
},
18+
"keywords": [
19+
"git",
20+
"tag",
21+
"tags",
22+
"count",
23+
"count-git-tags"
24+
],
25+
"author": "Lukas Aichbauer <l.aichbauer@gmail.com>",
26+
"license": "MIT",
27+
"bugs": {
28+
"url": "https://github.com/aichbauer/node-count-git-tags/issues"
29+
},
30+
"ava": {
31+
"require": "babel-register",
32+
"babel": "inherit"
33+
},
34+
"homepage": "https://github.com/aichbauer/node-count-git-tags#readme",
35+
"dependencies": {
36+
"execa": "^0.6.1",
37+
"fs-extra": "^3.0.1",
38+
"is-git-repository": "^1.1.1",
39+
"path-is-absolute": "^1.0.1"
40+
},
41+
"devDependencies": {
42+
"ava": "^0.18.2",
43+
"babel-cli": "^6.24.0",
44+
"babel-plugin-add-module-exports": "^0.2.1",
45+
"babel-preset-env": "^1.2.2",
46+
"coveralls": "^2.12.0",
47+
"eslint": "^3.18.0",
48+
"eslint-config-airbnb-base": "^11.1.1",
49+
"eslint-plugin-import": "^2.2.0",
50+
"husky": "^0.13.2",
51+
"nyc": "^10.1.2"
52+
}
53+
}

0 commit comments

Comments
 (0)