From 132919890f10e8eaa64cdc499bea3613717f4fe9 Mon Sep 17 00:00:00 2001 From: Stephen Lautier Date: Wed, 29 Mar 2017 18:47:50 +0200 Subject: [PATCH 1/2] added definitions for multimatch --- types/multimatch/index.d.ts | 73 ++++++++++++++++++++++++++++ types/multimatch/multimatch-tests.ts | 8 +++ types/multimatch/tsconfig.json | 22 +++++++++ types/multimatch/tslint.json | 1 + 4 files changed, 104 insertions(+) create mode 100644 types/multimatch/index.d.ts create mode 100644 types/multimatch/multimatch-tests.ts create mode 100644 types/multimatch/tsconfig.json create mode 100644 types/multimatch/tslint.json diff --git a/types/multimatch/index.d.ts b/types/multimatch/index.d.ts new file mode 100644 index 0000000000..5a1c1daab9 --- /dev/null +++ b/types/multimatch/index.d.ts @@ -0,0 +1,73 @@ +// Type definitions for multimatch 2.1 +// Project: https://github.com/sindresorhus/multimatch +// Definitions by: Stephen Lautier +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Match utility function which supports multiple pattern globbing. + * + * @param {string[]} paths list to match against. + * @param {string[]} patterns globbing patterns to use. e.g. `[*, "!cake"]`. + * @param {multimatch.MultimatchOptions} [options] + * @returns {string[]} + */ +declare function multimatch(paths: string[], patterns: string[], options?: multimatch.MultimatchOptions): string[]; + +declare namespace multimatch { + + /** + * Options based on [minimatch](https://github.com/isaacs/minimatch#minimatchmatchlist-pattern-options) + */ + interface MultimatchOptions { + /** Dump a ton of stuff to stderr. */ + debug?: boolean; + + /** Do not expand `{a,b}` and `{1..3}` brace sets. */ + nobrace?: boolean; + + /** Disable `**` matching against multiple folder names. */ + noglobstar?: boolean; + + /** + * Allow patterns to match filenames starting with a period, even if + * the pattern does not explicitly have a period in that spot. + * + * Note that by default, `a/** /b` will **not** match `a/.d/b`, unless `dot` is set. + */ + dot?: boolean; + + /** Disable "extglob" style patterns like `+(a|b)`. */ + noext?: boolean; + + /** Perform a case-insensitive match. */ + nocase?: boolean; + + /** + * When a match is not found by `minimatch.match`, return a list containing + * the pattern itself if this option is set. When not set, an empty list + * is returned if there are no matches. + */ + nonull?: boolean; + + /** + * If set, then patterns without slashes will be matched + * against the basename of the path if it contains slashes. For example, + * `a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`. + */ + matchBase?: boolean; + + /** Suppress the behavior of treating `#` at the start of a pattern as a comment. */ + nocomment?: boolean; + + /** Suppress the behavior of treating a leading `!` character as negation. */ + nonegate?: boolean; + + /** Returns from negate expressions the same as if they were not negated. + * (Ie, true on a hit, false on a miss.) + */ + flipNegate?: boolean; + } + +} + +export = multimatch; diff --git a/types/multimatch/multimatch-tests.ts b/types/multimatch/multimatch-tests.ts new file mode 100644 index 0000000000..e867848b28 --- /dev/null +++ b/types/multimatch/multimatch-tests.ts @@ -0,0 +1,8 @@ +import * as multimatch from "multimatch"; + +const options: multimatch.MultimatchOptions = { + debug: true +}; + +multimatch(["unicorn", "cake", "rainbows"], ["*", "!cake"]); +multimatch(["unicorn", "cake", "rainbows"], ["*", "!cake"], options); diff --git a/types/multimatch/tsconfig.json b/types/multimatch/tsconfig.json new file mode 100644 index 0000000000..3f5a4db2ac --- /dev/null +++ b/types/multimatch/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "multimatch-tests.ts" + ] +} diff --git a/types/multimatch/tslint.json b/types/multimatch/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/types/multimatch/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 31aa4d57dcf78c4f92c1e8cb8ecfd49bde225fb7 Mon Sep 17 00:00:00 2001 From: Stephen Lautier Date: Wed, 29 Mar 2017 19:12:45 +0200 Subject: [PATCH 2/2] changed patterns to be either array or string --- types/multimatch/index.d.ts | 2 +- types/multimatch/multimatch-tests.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/types/multimatch/index.d.ts b/types/multimatch/index.d.ts index 5a1c1daab9..7130cafbd0 100644 --- a/types/multimatch/index.d.ts +++ b/types/multimatch/index.d.ts @@ -11,7 +11,7 @@ * @param {multimatch.MultimatchOptions} [options] * @returns {string[]} */ -declare function multimatch(paths: string[], patterns: string[], options?: multimatch.MultimatchOptions): string[]; +declare function multimatch(paths: string[], patterns: string | string[], options?: multimatch.MultimatchOptions): string[]; declare namespace multimatch { diff --git a/types/multimatch/multimatch-tests.ts b/types/multimatch/multimatch-tests.ts index e867848b28..b8c9cac658 100644 --- a/types/multimatch/multimatch-tests.ts +++ b/types/multimatch/multimatch-tests.ts @@ -4,5 +4,6 @@ const options: multimatch.MultimatchOptions = { debug: true }; +multimatch(["unicorn", "cake", "rainbows"], "!cake"); multimatch(["unicorn", "cake", "rainbows"], ["*", "!cake"]); multimatch(["unicorn", "cake", "rainbows"], ["*", "!cake"], options);