From 9638b7447a9e346f7e8ac678d8bbe2770ea65abd Mon Sep 17 00:00:00 2001 From: Timothy Jones Date: Fri, 13 Aug 2021 00:09:38 +1000 Subject: [PATCH] feat: Add typescript types --- index.d.ts | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 51 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..583bad7 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,50 @@ +import { SemVer } from "semver"; + +type GitInfo = { + dirty: boolean; + raw: string; + hash: string; + distance: null | number; + tag: null | string; + semver: null | SemVer; + suffix: string; + semverString: null | string; + toString: () => string; +}; +type GitDescribeOptions = { + dirtyMark?: string; + dirtySemver?: boolean; + longSemver?: boolean; + requireAnnotated?: boolean; + match?: string; + customArguments?: Array; +}; + +type Callback = (err: Error, gitInfo: GitInfo) => void; + +declare function gitDescribe(directory: string): Promise; +declare function gitDescribe(options: GitDescribeOptions): Promise; +declare function gitDescribe( + directory: string, + options: GitDescribeOptions +): Promise; + +declare function gitDescribe(callback: Callback): void; +declare function gitDescribe( + options: GitDescribeOptions, + callback: Callback +): void; +declare function gitDescribe(directory: string, callback: Callback): void; +declare function gitDescribe( + directory: string, + options: GitDescribeOptions, + callback: Callback +): void; + +declare function gitDescribeSync(): GitInfo; +declare function gitDescribeSync(directory: string): GitInfo; +declare function gitDescribeSync(options: GitDescribeOptions): GitInfo; +declare function gitDescribeSync( + directory: string, + options: GitDescribeOptions +): GitInfo; diff --git a/package.json b/package.json index d051756..b3d3e94 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ }, "homepage": "https://github.com/tvdstaaij/node-git-describe#readme", "dependencies": { + "@types/semver": "^7.3.8", "lodash": "^4.17.21" }, "optionalDependencies": {