mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
feat(git-branch-is): new type definition for v3.1 (#42811)
- definition files - test coverage https://github.com/kevinoid/git-branch-is#api-usage Thanks!
This commit is contained in:
parent
13d2990c13
commit
5fff1d9bd5
39
types/git-branch-is/git-branch-is-tests.ts
Normal file
39
types/git-branch-is/git-branch-is-tests.ts
Normal file
@ -0,0 +1,39 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import gitBranchIs = require('git-branch-is');
|
||||
|
||||
gitBranchIs('master', (err, result) => {
|
||||
if (err) console.error(err);
|
||||
else console.log(result ? 'On master' : 'Not on master');
|
||||
});
|
||||
|
||||
gitBranchIs('master').then(
|
||||
result => {
|
||||
console.log(result ? 'On master' : 'Not on master');
|
||||
},
|
||||
err => {
|
||||
console.error(err);
|
||||
},
|
||||
);
|
||||
|
||||
gitBranchIs(branchName => {
|
||||
return /^master$/.test(branchName);
|
||||
}).then(
|
||||
result => {
|
||||
console.log(result ? 'On master' : 'Not on master');
|
||||
},
|
||||
err => {
|
||||
console.error(err);
|
||||
},
|
||||
);
|
||||
|
||||
gitBranchIs(branchName => {
|
||||
return Promise.resolve(branchName === 'master');
|
||||
}).then(
|
||||
result => {
|
||||
console.log(result ? 'On master' : 'Not on master');
|
||||
},
|
||||
err => {
|
||||
console.error(err);
|
||||
},
|
||||
);
|
||||
55
types/git-branch-is/index.d.ts
vendored
Normal file
55
types/git-branch-is/index.d.ts
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
// Type definitions for git-branch-is 3.1
|
||||
// Project: https://github.com/kevinoid/git-branch-is
|
||||
// Definitions by: Piotr Błażejewicz (Peter Blazejewicz) <https://github.com/peterblazejewicz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Checks that the current branch of a git repository has a given name
|
||||
*/
|
||||
declare function gitBranchIs(branchNameOrTest: BranchNameOrTest, options?: Options): Promise<boolean>;
|
||||
declare function gitBranchIs(branchNameOrTest: BranchNameOrTest, callback: Callback): void;
|
||||
declare function gitBranchIs(branchNameOrTest: BranchNameOrTest, options: Options, callback?: Callback): void;
|
||||
|
||||
/**
|
||||
* test function to apply to the branch name
|
||||
*/
|
||||
type BranchNameTest = (branchName: string) => boolean | Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Expected name of current branch
|
||||
* or a test function to apply to the branch name
|
||||
*/
|
||||
type BranchNameOrTest = string | BranchNameTest;
|
||||
/**
|
||||
* function called with the return value of <code>branchNameOrTest</code> if it is a function,
|
||||
* or the result of identity checking <code>branchNameOrTest</code> to the
|
||||
* current branch name
|
||||
*/
|
||||
type Callback = (error: Error | null, result?: boolean) => void;
|
||||
|
||||
/**
|
||||
* Options for {@link gitBranchIs}.
|
||||
*/
|
||||
interface Options {
|
||||
/**
|
||||
* Current working directory where the branch name is
|
||||
* tested
|
||||
*/
|
||||
cwd?: string;
|
||||
/**
|
||||
* Extra arguments to pass to git
|
||||
*/
|
||||
gitArgs?: string[];
|
||||
/**
|
||||
* Path to the repository (i.e.
|
||||
* <code>--git-dir=</code> option to <code>git</code>).
|
||||
*/
|
||||
gitDir?: string;
|
||||
/**
|
||||
* Git binary name or path to use (default:
|
||||
* <code>'git'</code>).
|
||||
*/
|
||||
gitPath?: string;
|
||||
}
|
||||
|
||||
export = gitBranchIs;
|
||||
23
types/git-branch-is/tsconfig.json
Normal file
23
types/git-branch-is/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-branch-is-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/git-branch-is/tslint.json
Normal file
1
types/git-branch-is/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user