From 5934d79207f60419f5e14942d2124a36959b0cbd Mon Sep 17 00:00:00 2001 From: Santi Date: Mon, 15 May 2023 14:06:20 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#65496=20Added=20de?= =?UTF-8?q?finitions=20for=20"git-init"=20(supersedes=20#65055).=20by=20@s?= =?UTF-8?q?anti100a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * initial commit for git-init * modified * addressed @jakebailey's code review --- types/git-init/git-init-tests.ts | 14 ++++++++++++++ types/git-init/index.d.ts | 23 +++++++++++++++++++++++ types/git-init/tsconfig.json | 23 +++++++++++++++++++++++ types/git-init/tslint.json | 1 + 4 files changed, 61 insertions(+) create mode 100644 types/git-init/git-init-tests.ts create mode 100644 types/git-init/index.d.ts create mode 100644 types/git-init/tsconfig.json create mode 100644 types/git-init/tslint.json diff --git a/types/git-init/git-init-tests.ts b/types/git-init/git-init-tests.ts new file mode 100644 index 0000000000..0d18d07378 --- /dev/null +++ b/types/git-init/git-init-tests.ts @@ -0,0 +1,14 @@ +import init = require('git-init'); + +// $ExpectType void +init((err: Error | null, stdout: any, stderr: any) => { + // something here +}); +// $ExpectType void +init('./something/', (err: Error | null, stdout: any, stderr: any) => { + // something here +}); +// @ts-expect-error +init(5); +// @ts-expect-error +init('./something', 5); diff --git a/types/git-init/index.d.ts b/types/git-init/index.d.ts new file mode 100644 index 0000000000..f07e60a521 --- /dev/null +++ b/types/git-init/index.d.ts @@ -0,0 +1,23 @@ +// Type definitions for git-init 1.0 +// Project: https://github.com/yoshuawuyts/git-init#readme +// Definitions by: Santi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +import type { ExecException } from 'node:child_process'; + +type ExecCallback = (error: ExecException | null, stdout: string, stderr: string) => void; +/** + * Initializes a new Git repo in `path` asynchronously. + * + * @param path The path of the folder to be initialized as a Git repo. + * @param cb An `exec`-compatible callback defined in {@link ExecCallback}. + */ +declare function init(path: string, cb: ExecCallback): void; +/** + * Initializes a new Git repo in the current directory asynchronously. + * + * @param cb An `exec`-compatible callback defined in {@link ExecCallback}. + */ +declare function init(cb: ExecCallback): void; +export = init; diff --git a/types/git-init/tsconfig.json b/types/git-init/tsconfig.json new file mode 100644 index 0000000000..b56f2be15a --- /dev/null +++ b/types/git-init/tsconfig.json @@ -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-init-tests.ts" + ] +} diff --git a/types/git-init/tslint.json b/types/git-init/tslint.json new file mode 100644 index 0000000000..794cb4bf3e --- /dev/null +++ b/types/git-init/tslint.json @@ -0,0 +1 @@ +{ "extends": "@definitelytyped/dtslint/dt.json" }