Merge pull request #21448 from mrmlnc/bash_glob

[bash-glob] Add typings for "bash-glob" package
This commit is contained in:
Nathan Shively-Sanders
2017-11-14 08:17:16 -08:00
committed by GitHub
4 changed files with 81 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import bashGlob = require('bash-glob');
bashGlob('pattern', (err, files) => {});
bashGlob(['pattern'], (err, files) => {});
bashGlob(['pattern'], {}, (err, files) => {});
bashGlob(['pattern'], { cwd: 'cwd' }, (err, files) => { });
bashGlob.on('match', (match, cwd) => {});
bashGlob.on('files', (files, cwd) => {});
bashGlob.on('end', (files) => {});
bashGlob.each('pattern', (err, files) => {});
bashGlob.each(['pattern'], (err, files) => {});
bashGlob.each(['pattern'], {}, (err, files) => {});
bashGlob.each(['pattern'], { cwd: 'cwd' }, (err, files) => {});
// $ExpectType string[]
bashGlob.sync('pattern');
bashGlob.sync(['pattern']);
bashGlob.sync(['pattern'], {});
bashGlob.sync(['pattern'], { cwd: 'cwd' });

36
types/bash-glob/index.d.ts vendored Normal file
View File

@@ -0,0 +1,36 @@
// Type definitions for bash-glob 2.0
// Project: https://github.com/micromatch/bash-glob
// Definitions by: mrmlnc <https://github.com/mrmlnc>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
type Patterns = string | string[];
type Callback = (err: Error, files: string[]) => void;
declare function bashGlob(pattern: Patterns, callback: Callback): void;
declare function bashGlob(pattern: Patterns, options: bashGlob.Options, callback: Callback): void;
declare namespace bashGlob {
interface Options {
cwd?: string;
dot?: boolean;
dotglob?: boolean;
extglob?: boolean;
failglob?: boolean;
globstar?: boolean;
nocase?: boolean;
nocaseglob?: boolean;
nullglob?: boolean;
}
function on(event: 'match' | 'files', callback: (files: string, cwd: string) => void): void;
function on(event: 'end', callback: (files: string) => void): void;
function each(patterns: Patterns, callback: Callback): void;
function each(patterns: Patterns, options: Options, callback: Callback): void;
function promise(patterns: Patterns, options?: Options): Promise<string[]>;
function sync(patterns: Patterns, options?: Options): string[];
}
export = bashGlob;

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"bash-glob-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }