Skip to content

Commit bc8bca8

Browse files
author
roman.vasilev
committed
feat: Initial implementation
1 parent 29d312b commit bc8bca8

File tree

4 files changed

+32
-49
lines changed

4 files changed

+32
-49
lines changed

README.md

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,4 @@
1-
# node-package-starter
1+
# git-last-tag
22

3-
## Table of Contents
4-
5-
- [Install](#install)
6-
7-
- - [Frontend](#frontend)
8-
9-
- [Changelog](#changelog)
10-
11-
- [License](#license)
12-
13-
## Install
14-
15-
git clone https://github.com/unlight/node-package-starte
16-
17-
#### Frontend
18-
19-
npm run setupfrontend
20-
21-
## Changelog
22-
23-
See [CHANGELOG.md](CHANGELOG.md)
24-
25-
## License
26-
27-
[MIT](LICENSE) © 2019
3+
## TODO
4+
* Unit tests

ng-package.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

package.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"name": "node-package-starter",
2+
"name": "git-last-tag",
33
"version": "0.0.0-dev",
44
"license": "MIT",
5-
"description": "",
5+
"description": "## Table of Contents",
66
"main": "index.js",
77
"typings": "index.d.ts",
88
"author": "2019",
@@ -27,17 +27,18 @@
2727
"lint:w": "run-p tsclint:w eslint:w",
2828
"semantic-release": "semantic-release",
2929
"prepublishOnly": "sed -i -e 's/devDependencies/_devDependencies/g' package.json",
30-
"copySource": "cp -rv src dist && find dist/src -name '*.spec.ts' | xargs rm -f",
3130
"build": "sh Taskfile build",
3231
"remark": "sh Taskfile remark_run",
3332
"remark:update": "sh Taskfile remark_run --output",
34-
"setupfrontend": "pnpm i -D ng-packagr @angular/core @angular/compiler-cli @angular/compiler tsickle",
3533
"commit": "git-cz"
3634
},
3735
"keywords": [],
3836
"repository": {
3937
"type": "git",
40-
"url": "https://github.com/unlight/node-package-starter.git"
38+
"url": "git+https://github.com/unlight/git-last-tag.git"
39+
},
40+
"dependencies": {
41+
"tslib": "^1.9.3"
4142
},
4243
"devDependencies": {
4344
"@semantic-release/changelog": "^3.0.2",
@@ -74,5 +75,9 @@
7475
"commitizen": {
7576
"path": "cz-conventional-changelog"
7677
}
77-
}
78+
},
79+
"bugs": {
80+
"url": "https://github.com/unlight/git-last-tag/issues"
81+
},
82+
"homepage": "https://github.com/unlight/git-last-tag#readme"
7883
}

src/index.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1-
/**
2-
* Hello function whithout parameter
3-
* @returns result string
4-
*/
5-
export function hello(): string;
1+
import { execSync } from 'child_process';
2+
3+
export const SEMANTIC_VERSION = 'v[0-9]*\\.[0-9]*\\.[0-9]*';
4+
5+
// todo: git describe --tags `git rev-list --tags="v[0-9]*\.[0-9]*\.[0-9]*" --max-count=1`
6+
export function getLastTagSync(match?: string) {
7+
let tagsOption = '--tags';
8+
if (match) {
9+
tagsOption = `--tags="${match}"`;
10+
}
11+
const ref = execSync(`git rev-list --max-count=1 ${tagsOption}`, { encoding: 'utf8' });
12+
const tag = execSync(`git describe --tags ${ref}`, { encoding: 'utf8' });
13+
return tag;
14+
}
615

716
/**
8-
* This is hello function
9-
* @returns result string
17+
* todo: make it real async
1018
*/
11-
export function hello(greet?: string) {
12-
return `${greet} world`;
19+
export async function getLastTag() {
20+
const result = getLastTagSync();
21+
return result;
1322
}

0 commit comments

Comments
 (0)