Skip to content

Commit

Permalink
feat: Add typescript types
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyJones committed Aug 12, 2021
1 parent 0469061 commit 9638b74
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
50 changes: 50 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -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<string>;
};

type Callback = (err: Error, gitInfo: GitInfo) => void;

declare function gitDescribe(directory: string): Promise<GitInfo>;
declare function gitDescribe(options: GitDescribeOptions): Promise<GitInfo>;
declare function gitDescribe(
directory: string,
options: GitDescribeOptions
): Promise<GitInfo>;

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;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
},
"homepage": "https://github.com/tvdstaaij/node-git-describe#readme",
"dependencies": {
"@types/semver": "^7.3.8",
"lodash": "^4.17.21"
},
"optionalDependencies": {
Expand Down

0 comments on commit 9638b74

Please sign in to comment.