mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
feat: add typings for git-diff-parser module (#43599)
This commit is contained in:
parent
9a2f620ce7
commit
7c71949f51
19
types/git-diff-parser/git-diff-parser-tests.ts
Normal file
19
types/git-diff-parser/git-diff-parser-tests.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import parser = require("git-diff-parser");
|
||||
|
||||
const input = `commit cd4a4e2db47f9642cf322fe109b5bfb3f6eb23c7 (HEAD -> master, origin/master, origin/HEAD)
|
||||
Author: John Doe <johndoe@google.com>
|
||||
Date: Thu Apr 1 23:59:59 2020 -0100
|
||||
|
||||
Just a typical commit message
|
||||
|
||||
diff --git a/types/pkg/index.d.ts b/types/pkg/index.d.ts
|
||||
index 60bb057b92..5c25c419d1 100644
|
||||
--- a/types/pkg/index.d.ts
|
||||
+++ b/types/pkg/index.d.ts
|
||||
@@ -3,3 +3,3 @@ declare namespace A {
|
||||
*/
|
||||
- aaa
|
||||
+ bbb
|
||||
/**`;
|
||||
|
||||
parser(input); // $ExpectType Result
|
||||
67
types/git-diff-parser/index.d.ts
vendored
Normal file
67
types/git-diff-parser/index.d.ts
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
// Type definitions for git-diff-parser 1.0
|
||||
// Project: https://github.com/spookd/git-diff-parser
|
||||
// Definitions by: Alexey Yaroshevich <https://github.com/qfox>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types='node' />
|
||||
|
||||
declare function GitDiffParser(input: string | Buffer): GitDiffParser.Result;
|
||||
declare namespace GitDiffParser {
|
||||
/** Represents prefix in `git diff` output: '+', '-', or space */
|
||||
type LineType = 'deleted' | 'added' | 'normal';
|
||||
|
||||
interface Line {
|
||||
type: LineType;
|
||||
|
||||
/** Has line break. Always false for added failes */
|
||||
break: boolean;
|
||||
|
||||
/** Content of removed or added string */
|
||||
text: string;
|
||||
|
||||
/** The main line number */
|
||||
ln1: number;
|
||||
|
||||
/** New line number (for type normal) */
|
||||
ln2?: number;
|
||||
}
|
||||
|
||||
interface File {
|
||||
deleted: boolean;
|
||||
added: boolean;
|
||||
renamed: boolean;
|
||||
binary: boolean;
|
||||
lines: Line[];
|
||||
index?: string[];
|
||||
oldName?: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface Commit {
|
||||
files: File[];
|
||||
}
|
||||
|
||||
interface DetailedCommit extends Commit {
|
||||
message?: string;
|
||||
sha?: string;
|
||||
date?: Date;
|
||||
author?: string;
|
||||
email?: string;
|
||||
}
|
||||
|
||||
interface Result {
|
||||
detailed: boolean;
|
||||
commits: Commit[];
|
||||
}
|
||||
|
||||
interface DryResult extends Result {
|
||||
detailed: false;
|
||||
}
|
||||
|
||||
interface DetailedResult extends Result {
|
||||
detailed: true;
|
||||
commits: DetailedCommit[];
|
||||
}
|
||||
}
|
||||
|
||||
export = GitDiffParser;
|
||||
23
types/git-diff-parser/tsconfig.json
Normal file
23
types/git-diff-parser/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"git-diff-parser-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/git-diff-parser/tslint.json
Normal file
1
types/git-diff-parser/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user