mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Merge pull request #22253 from vemoo/master
update micromatch and add braces
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import braces = require("braces");
|
||||
|
||||
const bracesOpts: braces.Options = {
|
||||
expand: true,
|
||||
};
|
||||
|
||||
let strArrResult: string[];
|
||||
|
||||
strArrResult = braces.expand('a/{x,y,z}/b');
|
||||
strArrResult = braces('a/{x,y,z}/b', bracesOpts);
|
||||
Vendored
+110
@@ -0,0 +1,110 @@
|
||||
// Type definitions for braces 2.3
|
||||
// Project: https://github.com/micromatch/braces
|
||||
// Definitions by: vemoo <https://github.com/vemoo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace braces {
|
||||
interface Options {
|
||||
/**
|
||||
* Generate an "expanded" brace pattern (this option is unncessary with the `.expand` method, which does the same thing).
|
||||
*
|
||||
* ```js
|
||||
* console.log(braces('a/{b,c}/d', {expand: true}));
|
||||
* //=> [ 'a/b/d', 'a/c/d' ]
|
||||
* ```
|
||||
*
|
||||
* @default undefined
|
||||
*/
|
||||
expand?: boolean;
|
||||
/**
|
||||
* Enabled by default.
|
||||
*
|
||||
* ```js
|
||||
* console.log(braces('a/{b,c}/d'));
|
||||
* //=> [ 'a/(b|c)/d' ]
|
||||
* ```
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
optimize?: boolean;
|
||||
/**
|
||||
* Duplicates are removed by default. To keep duplicates, pass `{nodupes: false}` on the options
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
nodupes?: boolean;
|
||||
/**
|
||||
* When `braces.expand()` is used, or `options.expand` is true, brace patterns will automatically be [optimized](#optionsoptimize)
|
||||
* when the difference between the range minimum and range maximum exceeds the `rangeLimit`.
|
||||
* This is to prevent huge ranges from freezing your application.
|
||||
*
|
||||
* You can set this to any number, or change `options.rangeLimit` to `Inifinity` to disable this altogether.
|
||||
*
|
||||
* @default 250
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // pattern exceeds the "rangeLimit", so it's optimized automatically
|
||||
* console.log(braces.expand('{1..1000}'));
|
||||
* //=> ['([1-9]|[1-9][0-9]{1,2}|1000)']
|
||||
*
|
||||
* // pattern does not exceed "rangeLimit", so it's NOT optimized
|
||||
* console.log(braces.expand('{1..100}'));
|
||||
* //=> ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11' ... '89', 90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '100']
|
||||
* ```
|
||||
*/
|
||||
rangeLimit?: number;
|
||||
/**
|
||||
* Customize range expansion.
|
||||
*
|
||||
* ```js
|
||||
* var range = braces.expand('x{a..e}y', {
|
||||
* transform: function(str) {
|
||||
* return 'foo' + str;
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* console.log(range);
|
||||
* //=> [ 'xfooay', 'xfooby', 'xfoocy', 'xfoody', 'xfooey' ]
|
||||
* ```
|
||||
*
|
||||
* @default undefined
|
||||
*/
|
||||
transform?: (str: string) => string;
|
||||
/**
|
||||
* In regular expressions, quanitifiers can be used to specify how many times a token can be repeated. For example, `a{1,3}` will match the letter `a` one to three times.
|
||||
*
|
||||
* Unfortunately, regex quantifiers happen to share the same syntax as [Bash lists](#lists)
|
||||
*
|
||||
* The `quantifiers` option tells braces to detect when [regex quantifiers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#quantifiers)
|
||||
* are defined in the given pattern, and not to try to expand them as lists.
|
||||
*
|
||||
* @default undefined
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* var braces = require('braces');
|
||||
* console.log(braces('a/b{1,3}/{x,y,z}'));
|
||||
* //=> [ 'a/b(1|3)/(x|y|z)' ]
|
||||
* console.log(braces('a/b{1,3}/{x,y,z}', {quantifiers: true}));
|
||||
* //=> [ 'a/b{1,3}/(x|y|z)' ]
|
||||
* console.log(braces('a/b{1,3}/{x,y,z}', {quantifiers: true, expand: true}));
|
||||
* //=> [ 'a/b{1,3}/x', 'a/b{1,3}/y', 'a/b{1,3}/z' ]
|
||||
* ```
|
||||
*/
|
||||
quantifiers?: boolean;
|
||||
/**
|
||||
* Strip backslashes that were used for escaping from the result.
|
||||
*
|
||||
* @default undefined
|
||||
*/
|
||||
unescape?: boolean;
|
||||
}
|
||||
}
|
||||
interface Braces {
|
||||
(pattern: string, options?: braces.Options): string[];
|
||||
expand(pattern: string): string[];
|
||||
}
|
||||
declare const braces: Braces;
|
||||
export as namespace braces;
|
||||
export = braces;
|
||||
@@ -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",
|
||||
"braces-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
@@ -9,6 +9,11 @@
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"paths": {
|
||||
"micromatch": [
|
||||
"micromatch/v2"
|
||||
]
|
||||
},
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
"paths": {
|
||||
"gulp": [
|
||||
"gulp/v3"
|
||||
],
|
||||
"micromatch": [
|
||||
"micromatch/v2"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
|
||||
Vendored
+563
-109
@@ -1,171 +1,625 @@
|
||||
// Type definitions for micromatch 2.3.7
|
||||
// Project: https://github.com/jonschlinkert/micromatch
|
||||
// Type definitions for micromatch 3.1
|
||||
// Project: https://github.com/micromatch/micromatch
|
||||
// Definitions by: glen-84 <https://github.com/glen-84>
|
||||
// vemoo <https://github.com/vemoo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import parseGlob = require('parse-glob');
|
||||
|
||||
import * as braces from "braces";
|
||||
declare namespace micromatch {
|
||||
type MatchFunction<T> = ((value: T) => boolean);
|
||||
type Pattern = (string | RegExp | MatchFunction<string>);
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
* Normalize slashes in file paths and glob patterns to forward slashes.
|
||||
* Allow glob patterns without slashes to match a file path based on its basename. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `matchBase`.
|
||||
*
|
||||
* @default false
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* mm(['a/b.js', 'a/c.md'], '*.js');
|
||||
* //=> []
|
||||
*
|
||||
* mm(['a/b.js', 'a/c.md'], '*.js', {matchBase: true});
|
||||
* //=> ['a/b.js']
|
||||
* ```
|
||||
*/
|
||||
unixify?: boolean;
|
||||
basename?: boolean;
|
||||
/**
|
||||
* Match dotfiles. Same behavior as minimatch.
|
||||
* Enabled by default, this option enforces bash-like behavior with stars immediately following a bracket expression.
|
||||
* Bash bracket expressions are similar to regex character classes, but unlike regex, a star following a bracket expression **does not repeat the bracketed characters**.
|
||||
* Instead, the star is treated the same as an other star.
|
||||
*
|
||||
* @default true
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* var files = ['abc', 'ajz'];
|
||||
* console.log(mm(files, '[a-c]*'));
|
||||
* //=> ['abc', 'ajz']
|
||||
*
|
||||
* console.log(mm(files, '[a-c]*', {bash: false}));
|
||||
* ```
|
||||
*/
|
||||
bash?: boolean;
|
||||
/**
|
||||
* Disable regex and function memoization.
|
||||
*
|
||||
* @default undefined
|
||||
*/
|
||||
cache?: boolean;
|
||||
/**
|
||||
* Match dotfiles. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `dot`.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
dot?: boolean;
|
||||
/**
|
||||
* Unescape slashes in glob patterns. Use cautiously, especially on windows.
|
||||
* Similar to the `--failglob` behavior in Bash, throws an error when no matches are found.
|
||||
*
|
||||
* @default undefined
|
||||
*/
|
||||
unescape?: boolean;
|
||||
failglob?: boolean;
|
||||
/**
|
||||
* Remove duplicate elements from the result array.
|
||||
* String or array of glob patterns to match files to ignore.
|
||||
*
|
||||
* @default undefined
|
||||
*/
|
||||
nodupes?: boolean;
|
||||
ignore?: string | string[];
|
||||
/**
|
||||
* Allow glob patterns without slashes to match a file path based on its basename. Same behavior as
|
||||
* minimatch.
|
||||
* Alias for [options.basename](#options-basename).
|
||||
*/
|
||||
matchBase?: boolean;
|
||||
/**
|
||||
* Don't expand braces in glob patterns. Same behavior as minimatch nobrace.
|
||||
* Disable expansion of brace patterns. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `nobrace`.
|
||||
*
|
||||
* @default undefined
|
||||
*/
|
||||
nobraces?: boolean;
|
||||
nobrace?: boolean;
|
||||
/**
|
||||
* Don't expand POSIX bracket expressions.
|
||||
*/
|
||||
nobrackets?: boolean;
|
||||
/**
|
||||
* Don't expand extended globs.
|
||||
*/
|
||||
noextglob?: boolean;
|
||||
/**
|
||||
* Use a case-insensitive regex for matching files. Same behavior as minimatch.
|
||||
* Use a case-insensitive regex for matching files. Same behavior as [minimatch](https://github.com/isaacs/minimatch).
|
||||
*
|
||||
* @default undefined
|
||||
*/
|
||||
nocase?: boolean;
|
||||
/**
|
||||
* If true, when no matches are found the actual (array-ified) glob pattern is returned instead of an empty
|
||||
* array. Same behavior as minimatch.
|
||||
* Remove duplicate elements from the result array.
|
||||
*
|
||||
* @default undefined
|
||||
*
|
||||
* @example
|
||||
* Example of using the `unescape` and `nodupes` options together:
|
||||
*
|
||||
* ```js
|
||||
* mm.match(['a/b/c', 'a/b/c'], 'a/b/c');
|
||||
* //=> ['a/b/c', 'a/b/c']
|
||||
*
|
||||
* mm.match(['a/b/c', 'a/b/c'], 'a/b/c', {nodupes: true});
|
||||
* //=> ['abc']
|
||||
* ```
|
||||
*/
|
||||
nodupes?: boolean;
|
||||
/**
|
||||
* Disable extglob support, so that extglobs are regarded as literal characters.
|
||||
*
|
||||
* @default undefined
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* mm(['a/z', 'a/b', 'a/!(z)'], 'a/!(z)');
|
||||
* //=> ['a/b', 'a/!(z)']
|
||||
*
|
||||
* mm(['a/z', 'a/b', 'a/!(z)'], 'a/!(z)', {noext: true});
|
||||
* //=> ['a/!(z)'] (matches only as literal characters)
|
||||
* ```
|
||||
*/
|
||||
noext?: boolean;
|
||||
/**
|
||||
* Disallow negation (`!`) patterns, and treat leading `!` as a literal character to match.
|
||||
*
|
||||
* @default undefined
|
||||
*/
|
||||
nonegate?: boolean;
|
||||
/**
|
||||
* Disable matching with globstars (`**`).
|
||||
*
|
||||
* @default undefined
|
||||
*/
|
||||
noglobstar?: boolean;
|
||||
/**
|
||||
* Alias for [options.nullglob](#options-nullglob).
|
||||
*/
|
||||
nonull?: boolean;
|
||||
/**
|
||||
* Cache the platform (e.g. win32) to prevent this from being looked up for every file path.
|
||||
* If `true`, when no matches are found the actual (arrayified) glob pattern is returned instead of an empty array.
|
||||
* Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `nonull`.
|
||||
*
|
||||
* @default undefined
|
||||
*/
|
||||
cache?: boolean;
|
||||
}
|
||||
|
||||
interface Glob {
|
||||
options: micromatch.Options;
|
||||
pattern: string;
|
||||
history: { msg: any, pattern: string }[];
|
||||
tokens: parseGlob.Result;
|
||||
orig: string;
|
||||
negated: boolean;
|
||||
|
||||
nullglob?: boolean;
|
||||
/**
|
||||
* Initialize defaults.
|
||||
* Pass your own instance of [snapdragon](https://github.com/jonschlinkert/snapdragon), to customize parsers or compilers.
|
||||
*
|
||||
* @default undefined
|
||||
*/
|
||||
init(pattern: string): void;
|
||||
|
||||
snapdragon?: object;
|
||||
/**
|
||||
* Push a change into `glob.history`. Useful for debugging.
|
||||
* Generate a source map by enabling the `sourcemap` option with the `.parse`, `.compile`, or `.create` methods.
|
||||
*
|
||||
* _(Note that sourcemaps are currently not enabled for brace patterns)_
|
||||
*
|
||||
* @example
|
||||
* ``` js
|
||||
* var mm = require('micromatch');
|
||||
* var pattern = '*(*(of*(a)x)z)';
|
||||
*
|
||||
* var res = mm.create('abc/*.js', {sourcemap: true});
|
||||
* console.log(res.map);
|
||||
* // { version: 3,
|
||||
* // sources: [ 'string' ],
|
||||
* // names: [],
|
||||
* // mappings: 'AAAA,GAAG,EAAC,iBAAC,EAAC,EAAE',
|
||||
* // sourcesContent: [ 'abc/*.js' ] }
|
||||
*
|
||||
* var ast = mm.parse('abc/**\/*.js');
|
||||
* var res = mm.compile(ast, {sourcemap: true});
|
||||
* console.log(res.map);
|
||||
* // { version: 3,
|
||||
* // sources: [ 'string' ],
|
||||
* // names: [],
|
||||
* // mappings: 'AAAA,GAAG,EAAC,2BAAE,EAAC,iBAAC,EAAC,EAAE',
|
||||
* // sourcesContent: [ 'abc/**\/*.js' ] }
|
||||
*
|
||||
* var ast = mm.parse(pattern);
|
||||
* var res = mm.compile(ast, {sourcemap: true});
|
||||
* console.log(res.map);
|
||||
* // { version: 3,
|
||||
* // sources: [ 'string' ],
|
||||
* // names: [],
|
||||
* // mappings: 'AAAA,CAAE,CAAE,EAAE,CAAE,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC',
|
||||
* // sourcesContent: [ '*(*(of*(a)x)z)' ] }
|
||||
* ```
|
||||
*/
|
||||
track(msg: any): void;
|
||||
|
||||
sourcemap?: boolean;
|
||||
/**
|
||||
* Return true if `glob.pattern` was negated with `!`, also remove the `!` from the pattern.
|
||||
* Remove backslashes from returned matches.
|
||||
*
|
||||
* @default undefined
|
||||
*
|
||||
* @example
|
||||
* In this example we want to match a literal `*`:
|
||||
*
|
||||
* ```js
|
||||
* mm.match(['abc', 'a\\*c'], 'a\\*c');
|
||||
* //=> ['a\\*c']
|
||||
*
|
||||
* mm.match(['abc', 'a\\*c'], 'a\\*c', {unescape: true});
|
||||
* //=> ['a*c']
|
||||
* ```
|
||||
*/
|
||||
isNegated(): boolean;
|
||||
|
||||
unescape?: boolean;
|
||||
/**
|
||||
* Expand braces in the given glob pattern.
|
||||
* Convert path separators on returned files to posix/unix-style forward slashes.
|
||||
*
|
||||
* @default true
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* mm.match(['a\\b\\c'], 'a/**');
|
||||
* //=> ['a/b/c']
|
||||
*
|
||||
* mm.match(['a\\b\\c'], {unixify: false});
|
||||
* //=> ['a\\b\\c']
|
||||
* ```
|
||||
*/
|
||||
braces(): void;
|
||||
|
||||
/**
|
||||
* Expand bracket expressions in `glob.pattern`.
|
||||
*/
|
||||
brackets(): void;
|
||||
|
||||
/**
|
||||
* Expand extended globs in `glob.pattern`.
|
||||
*/
|
||||
extglob(): void;
|
||||
|
||||
/**
|
||||
* Parse the given pattern.
|
||||
*/
|
||||
parse(pattern: string): parseGlob.Result;
|
||||
|
||||
/**
|
||||
* Escape special characters in the given string.
|
||||
*/
|
||||
escape(pattern: string): string;
|
||||
|
||||
/**
|
||||
* Unescape special characters in the given string.
|
||||
*/
|
||||
unescape(pattern: string): string;
|
||||
}
|
||||
|
||||
interface GlobData {
|
||||
pattern: string;
|
||||
tokens: parseGlob.Result;
|
||||
options: micromatch.Options;
|
||||
unixify?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
interface Micromatch {
|
||||
(files: string | string[], patterns: micromatch.Pattern | micromatch.Pattern[]): string[];
|
||||
|
||||
isMatch: {
|
||||
/**
|
||||
* Returns true if a file path matches the given pattern.
|
||||
*/
|
||||
(filePath: string, pattern: micromatch.Pattern, opts?: micromatch.Options): boolean;
|
||||
/**
|
||||
* Returns a function for matching.
|
||||
*/
|
||||
(filePath: string, opts?: micromatch.Options): micromatch.MatchFunction<string>;
|
||||
};
|
||||
/**
|
||||
* The main function takes a list of strings and one or more glob patterns to use for matching.
|
||||
*
|
||||
* @param list A list of strings to match
|
||||
* @param patterns One or more glob patterns to use for matching.
|
||||
* @param options See available options for changing how matches are performed
|
||||
* @returns Returns an array of matches
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm(list, patterns[, options]);
|
||||
*
|
||||
* console.log(mm(['a.js', 'a.txt'], ['*.js']));
|
||||
* //=> [ 'a.js' ]
|
||||
* ```
|
||||
*/
|
||||
(list: string[], patterns: string | string[], options?: micromatch.Options): string[];
|
||||
|
||||
/**
|
||||
* Returns true if any part of a file path matches the given pattern. Think of this as "has path" versus
|
||||
* "is path".
|
||||
* Similar to the main function, but `pattern` must be a string.
|
||||
*
|
||||
* @param list Array of strings to match
|
||||
* @param pattern Glob pattern to use for matching.
|
||||
* @param options See available options for changing how matches are performed
|
||||
* @returns Returns an array of matches
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.match(list, pattern[, options]);
|
||||
*
|
||||
* console.log(mm.match(['a.a', 'a.aa', 'a.b', 'a.c'], '*.a'));
|
||||
* //=> ['a.a', 'a.aa']
|
||||
* ```
|
||||
*/
|
||||
contains(filePath: string, pattern: micromatch.Pattern, opts?: micromatch.Options): boolean;
|
||||
match(list: string[], pattern: string, options?: micromatch.Options): string[];
|
||||
|
||||
/**
|
||||
* Returns a function for matching using the supplied pattern. e.g. create your own "matcher". The advantage of
|
||||
* this method is that the pattern can be compiled outside of a loop.
|
||||
* Returns true if the specified `string` matches the given glob `pattern`.
|
||||
*
|
||||
* @param string String to match
|
||||
* @param pattern Glob pattern to use for matching.
|
||||
* @param options See available options for changing how matches are performed
|
||||
* @returns Returns true if the string matches the glob pattern.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.isMatch(string, pattern[, options]);
|
||||
*
|
||||
* console.log(mm.isMatch('a.a', '*.a'));
|
||||
* //=> true
|
||||
* console.log(mm.isMatch('a.b', '*.a'));
|
||||
* //=> false
|
||||
* ```
|
||||
*/
|
||||
matcher(pattern: micromatch.Pattern): micromatch.MatchFunction<string>;
|
||||
isMatch(string: string, pattern: string, options?: micromatch.Options): boolean;
|
||||
|
||||
/**
|
||||
* Returns a function that can be passed to Array#filter().
|
||||
* Returns true if some of the strings in the given `list` match any of the given glob `patterns`.
|
||||
*
|
||||
* @param list The string or array of strings to test. Returns as soon as the first match is found.
|
||||
* @param patterns One or more glob patterns to use for matching.
|
||||
* @param options See available options for changing how matches are performed
|
||||
* @returns Returns true if any patterns match `str`
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.some(list, patterns[, options]);
|
||||
*
|
||||
* console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
|
||||
* // true
|
||||
* console.log(mm.some(['foo.js'], ['*.js', '!foo.js']));
|
||||
* // false
|
||||
* ```
|
||||
*/
|
||||
filter(patterns: micromatch.Pattern | micromatch.Pattern[], opts?: micromatch.Options): micromatch.MatchFunction<any>;
|
||||
some(list: string | string[], patterns: string | string[], options?: micromatch.Options): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if a file path matches any of the given patterns.
|
||||
* Returns true if every string in the given `list` matches any of the given glob `patterns`.
|
||||
*
|
||||
* @param list The string or array of strings to test.
|
||||
* @param patterns One or more glob patterns to use for matching.
|
||||
* @param options See available options for changing how matches are performed
|
||||
* @returns Returns true if any patterns match `str`
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.every(list, patterns[, options]);
|
||||
*
|
||||
* console.log(mm.every('foo.js', ['foo.js']));
|
||||
* // true
|
||||
* console.log(mm.every(['foo.js', 'bar.js'], ['*.js']));
|
||||
* // true
|
||||
* console.log(mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
|
||||
* // false
|
||||
* console.log(mm.every(['foo.js'], ['*.js', '!foo.js']));
|
||||
* // false
|
||||
* ```
|
||||
*/
|
||||
any(filePath: string, patterns: micromatch.Pattern | micromatch.Pattern[], opts?: micromatch.Options): boolean;
|
||||
every(list: string | string[], patterns: string | string[], options?: micromatch.Options): boolean;
|
||||
|
||||
/**
|
||||
* Returns an object with a regex-compatible string and tokens.
|
||||
* Returns true if **any** of the given glob `patterns` match the specified `string`.
|
||||
*
|
||||
* @param str The string to test.
|
||||
* @param patterns One or more glob patterns to use for matching.
|
||||
* @param options See available options for changing how matches are performed
|
||||
* @returns Returns true if any patterns match `str`
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.any(string, patterns[, options]);
|
||||
*
|
||||
* console.log(mm.any('a.a', ['b.*', '*.a']));
|
||||
* //=> true
|
||||
* console.log(mm.any('a.a', 'b.*'));
|
||||
* //=> false
|
||||
* ```
|
||||
*/
|
||||
expand(pattern: string, opts?: micromatch.Options): micromatch.Glob | micromatch.GlobData;
|
||||
any(str: string | string[], patterns: string | string[], options?: micromatch.Options): boolean;
|
||||
|
||||
/**
|
||||
* Create a regular expression for matching file paths based on the given pattern.
|
||||
* Returns true if **all** of the given `patterns` match the specified string.
|
||||
*
|
||||
* @param str The string to test.
|
||||
* @param patterns One or more glob patterns to use for matching.
|
||||
* @param options See available options for changing how matches are performed
|
||||
* @returns Returns true if any patterns match `str`
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.all(string, patterns[, options]);
|
||||
*
|
||||
* console.log(mm.all('foo.js', ['foo.js']));
|
||||
* // true
|
||||
*
|
||||
* console.log(mm.all('foo.js', ['*.js', '!foo.js']));
|
||||
* // false
|
||||
*
|
||||
* console.log(mm.all('foo.js', ['*.js', 'foo.js']));
|
||||
* // true
|
||||
*
|
||||
* console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js']));
|
||||
* // true
|
||||
* ```
|
||||
*/
|
||||
makeRe(pattern: string, opts?: micromatch.Options): RegExp;
|
||||
all(str: string | string[], patterns: string | string[], options?: micromatch.Options): boolean;
|
||||
|
||||
/**
|
||||
* Returns a list of strings that _**do not match any**_ of the given `patterns`.
|
||||
*
|
||||
* @param list Array of strings to match.
|
||||
* @param patterns One or more glob pattern to use for matching.
|
||||
* @param options See available options for changing how matches are performed
|
||||
* @returns Returns an array of strings that **do not match** the given patterns.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.not(list, patterns[, options]);
|
||||
*
|
||||
* console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a'));
|
||||
* //=> ['b.b', 'c.c']
|
||||
* ```
|
||||
*/
|
||||
not(list: string[], patterns: string | string[], options?: micromatch.Options): string[];
|
||||
|
||||
/**
|
||||
* Returns true if the given `string` contains the given pattern. Similar to [.isMatch](#isMatch) but the pattern can match any part of the string.
|
||||
*
|
||||
* @param str The string to match.
|
||||
* @param patterns Glob pattern to use for matching.
|
||||
* @param options See available options for changing how matches are performed
|
||||
* @returns Returns true if the patter matches any part of `str`.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.contains(string, pattern[, options]);
|
||||
*
|
||||
* console.log(mm.contains('aa/bb/cc', '*b'));
|
||||
* //=> true
|
||||
* console.log(mm.contains('aa/bb/cc', '*d'));
|
||||
* //=> false
|
||||
* ```
|
||||
*/
|
||||
contains(str: string, patterns: string | string[], options?: micromatch.Options): boolean;
|
||||
|
||||
/**
|
||||
* Filter the keys of the given object with the given `glob` pattern and `options`. Does not attempt to match nested keys.
|
||||
* If you need this feature, use [glob-object](https://github.com/jonschlinkert/glob-object) instead.
|
||||
*
|
||||
* @param object The object with keys to filter.
|
||||
* @param patterns One or more glob patterns to use for matching.
|
||||
* @param options See available options for changing how matches are performed
|
||||
* @returns Returns an object with only keys that match the given patterns.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.matchKeys(object, patterns[, options]);
|
||||
*
|
||||
* var obj = { aa: 'a', ab: 'b', ac: 'c' };
|
||||
* console.log(mm.matchKeys(obj, '*b'));
|
||||
* //=> { ab: 'b' }
|
||||
* ```
|
||||
*/
|
||||
matchKeys<T>(object: T, patterns: string | string[], options?: micromatch.Options): Partial<T>;
|
||||
|
||||
/**
|
||||
* Returns a memoized matcher function from the given glob `pattern` and `options`. The returned function takes a string to match as its only argument and returns true if the string is a match.
|
||||
*
|
||||
* @param pattern Glob pattern
|
||||
* @param options See available options for changing how matches are performed.
|
||||
* @returns Returns a matcher function.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.matcher(pattern[, options]);
|
||||
*
|
||||
* var isMatch = mm.matcher('*.!(*a)');
|
||||
* console.log(isMatch('a.a'));
|
||||
* //=> false
|
||||
* console.log(isMatch('a.b'));
|
||||
* //=> true
|
||||
* ```
|
||||
*/
|
||||
matcher(pattern: string, options?: micromatch.Options): (str: string) => boolean;
|
||||
|
||||
/**
|
||||
* Returns an array of matches captured by `pattern` in `string, or`null` if the pattern did not match.
|
||||
*
|
||||
* @param pattern Glob pattern to use for matching.
|
||||
* @param string String to match
|
||||
* @param options See available options for changing how matches are performed
|
||||
* @returns Returns an array of captures if the string matches the glob pattern, otherwise `null`.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.capture(pattern, string[, options]);
|
||||
*
|
||||
* console.log(mm.capture('test/*.js', 'test/foo.js'));
|
||||
* //=> ['foo']
|
||||
* console.log(mm.capture('test/*.js', 'foo/bar.css'));
|
||||
* //=> null
|
||||
* ```
|
||||
*/
|
||||
capture(pattern: string, string: string, options?: micromatch.Options): string[] | null;
|
||||
|
||||
/**
|
||||
* Create a regular expression from the given glob `pattern`.
|
||||
*
|
||||
* @param pattern A glob pattern to convert to regex.
|
||||
* @param options See available options for changing how matches are performed.
|
||||
* @returns Returns a regex created from the given pattern.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.makeRe(pattern[, options]);
|
||||
*
|
||||
* console.log(mm.makeRe('*.js'));
|
||||
* //=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/
|
||||
* ```
|
||||
*/
|
||||
makeRe(pattern: string, options?: micromatch.Options): RegExp;
|
||||
|
||||
/**
|
||||
* Expand the given brace `pattern`.
|
||||
*
|
||||
* @param pattern String with brace pattern to expand.
|
||||
* @param options Any options to change how expansion is performed. See the [braces](https://github.com/micromatch/braces) library for all available options.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* console.log(mm.braces('foo/{a,b}/bar'));
|
||||
* //=> ['foo/(a|b)/bar']
|
||||
*
|
||||
* console.log(mm.braces('foo/{a,b}/bar', {expand: true}));
|
||||
* //=> ['foo/(a|b)/bar']
|
||||
* ```
|
||||
*/
|
||||
braces(pattern: string, options?: braces.Options): string[];
|
||||
|
||||
/**
|
||||
* Parses the given glob `pattern` and returns an array of abstract syntax trees (ASTs), with the compiled `output` and optional source `map` on each AST.
|
||||
*
|
||||
* @param pattern Glob pattern to parse and compile.
|
||||
* @param options Any options to change how parsing and compiling is performed.
|
||||
* @returns Returns an object with the parsed AST, compiled string and optional source map.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.create(pattern[, options]);
|
||||
*
|
||||
* console.log(mm.create('abc/*.js'));
|
||||
* // [{ options: { source: 'string', sourcemap: true },
|
||||
* // state: {},
|
||||
* // compilers:
|
||||
* // { ... },
|
||||
* // output: '(\\.[\\\\\\/])?abc\\/(?!\\.)(?=.)[^\\/]*?\\.js',
|
||||
* // ast:
|
||||
* // { type: 'root',
|
||||
* // errors: [],
|
||||
* // nodes:
|
||||
* // [ ... ],
|
||||
* // dot: false,
|
||||
* // input: 'abc/*.js' },
|
||||
* // parsingErrors: [],
|
||||
* // map:
|
||||
* // { version: 3,
|
||||
* // sources: [ 'string' ],
|
||||
* // names: [],
|
||||
* // mappings: 'AAAA,GAAG,EAAC,kBAAC,EAAC,EAAE',
|
||||
* // sourcesContent: [ 'abc/*.js' ] },
|
||||
* // position: { line: 1, column: 28 },
|
||||
* // content: {},
|
||||
* // files: {},
|
||||
* // idx: 6 }]
|
||||
* ```
|
||||
*/
|
||||
create(pattern: string, options?: micromatch.Options): object;
|
||||
|
||||
/**
|
||||
* Parse the given `str` with the given `options`.
|
||||
*
|
||||
* @returns Returns an AST
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.parse(pattern[, options]);
|
||||
*
|
||||
* var ast = mm.parse('a/{b,c}/d');
|
||||
* console.log(ast);
|
||||
* // { type: 'root',
|
||||
* // errors: [],
|
||||
* // input: 'a/{b,c}/d',
|
||||
* // nodes:
|
||||
* // [ { type: 'bos', val: '' },
|
||||
* // { type: 'text', val: 'a/' },
|
||||
* // { type: 'brace',
|
||||
* // nodes:
|
||||
* // [ { type: 'brace.open', val: '{' },
|
||||
* // { type: 'text', val: 'b,c' },
|
||||
* // { type: 'brace.close', val: '}' } ] },
|
||||
* // { type: 'text', val: '/d' },
|
||||
* // { type: 'eos', val: '' } ] }
|
||||
* ```
|
||||
*/
|
||||
parse(str: string, options?: micromatch.Options): object;
|
||||
|
||||
/**
|
||||
* Compile the given `ast` or string with the given `options`.
|
||||
*
|
||||
* @returns Returns an object that has an `output` property with the compiled string.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* var mm = require('micromatch');
|
||||
* mm.compile(ast[, options]);
|
||||
*
|
||||
* var ast = mm.parse('a/{b,c}/d');
|
||||
* console.log(mm.compile(ast));
|
||||
* // { options: { source: 'string' },
|
||||
* // state: {},
|
||||
* // compilers:
|
||||
* // { eos: [Function],
|
||||
* // noop: [Function],
|
||||
* // bos: [Function],
|
||||
* // brace: [Function],
|
||||
* // 'brace.open': [Function],
|
||||
* // text: [Function],
|
||||
* // 'brace.close': [Function] },
|
||||
* // output: [ 'a/(b|c)/d' ],
|
||||
* // ast:
|
||||
* // { ... },
|
||||
* // parsingErrors: [] }
|
||||
* ```
|
||||
*/
|
||||
compile(ast: object | string, options?: micromatch.Options): object;
|
||||
|
||||
/**
|
||||
* Clear the regex cache.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* mm.clearCache();
|
||||
* ```
|
||||
*/
|
||||
clearCache(): void;
|
||||
}
|
||||
|
||||
export as namespace micromatch;
|
||||
|
||||
declare const micromatch: Micromatch;
|
||||
export = micromatch;
|
||||
|
||||
@@ -1,54 +1,64 @@
|
||||
|
||||
import mm = require('micromatch');
|
||||
|
||||
var strArrResult: string[];
|
||||
var boolResult: boolean;
|
||||
var strMatchFuncResult: mm.MatchFunction<string>;
|
||||
var anyMatchFuncResult: mm.MatchFunction<any>;
|
||||
var globDataResult: mm.GlobData;
|
||||
var regExpResult: RegExp;
|
||||
// options type is accessible
|
||||
const micromatchOptions: mm.Options = {
|
||||
basename: true,
|
||||
dot: true,
|
||||
};
|
||||
|
||||
// Usage.
|
||||
strArrResult = mm(['a.js', 'b.md', 'c.txt'], '*.{js,txt}');
|
||||
let strArrResult: string[];
|
||||
let boolResult: boolean;
|
||||
|
||||
// Multiple patterns.
|
||||
strArrResult = mm(['a.md', 'b.js', 'c.txt', 'd.json'], ['*.md', '*.txt']);
|
||||
// main function
|
||||
strArrResult = mm(['a.js', 'a.txt'], '*.js', micromatchOptions);
|
||||
strArrResult = mm(['a.js', 'a.txt'], ['*.js']);
|
||||
|
||||
// "isMatch" method.
|
||||
boolResult = mm.isMatch('.verb.md', '*.md');
|
||||
boolResult = mm.isMatch('.verb.md', '*.md', {dot: true});
|
||||
boolResult = mm.isMatch('*.md', {dot: true})('.verb.md');
|
||||
// .match
|
||||
strArrResult = mm.match(['a.a', 'a.aa', 'a.b', 'a.c'], '*.a');
|
||||
|
||||
// "contains" method.
|
||||
boolResult = mm.contains('a/b/c', 'a/b');
|
||||
boolResult = mm.contains('a/b/c', 'a/b', {dot: true});
|
||||
// .isMatch
|
||||
boolResult = mm.isMatch('a.a', '*.a');
|
||||
|
||||
// "matcher" method.
|
||||
strMatchFuncResult = mm.matcher('*.md');
|
||||
strMatchFuncResult = mm.matcher(/\.md$/);
|
||||
strMatchFuncResult = mm.matcher((filePath: string) => true);
|
||||
// .some
|
||||
boolResult = mm.some('foo.js', '*.js');
|
||||
boolResult = mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js']);
|
||||
boolResult = mm.some(['foo.js', 'bar.js'], '*.js');
|
||||
|
||||
// "filter" method.
|
||||
anyMatchFuncResult = mm.filter('*.md');
|
||||
anyMatchFuncResult = mm.filter(/\.md$/);
|
||||
anyMatchFuncResult = mm.filter((filePath: string) => true);
|
||||
// .every
|
||||
boolResult = mm.every('foo.js', ['foo.js']);
|
||||
boolResult = mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js']);
|
||||
boolResult = mm.every(['foo.js', 'bar.js'], '*.js');
|
||||
|
||||
anyMatchFuncResult = mm.filter('*.md', {dot: true});
|
||||
['a.js', 'b.txt', 'c.md'].filter(anyMatchFuncResult);
|
||||
// .any
|
||||
boolResult = mm.any('foo.js', ['foo.js']);
|
||||
boolResult = mm.any(['foo.js', 'bar.js'], ['*.js', '!foo.js'], micromatchOptions);
|
||||
boolResult = mm.any(['foo.js', 'bar.js'], '*.js');
|
||||
|
||||
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
|
||||
anyMatchFuncResult = mm.filter(['{1..10}', '![7-9]', '!{3..4}']);
|
||||
arr.filter(anyMatchFuncResult);
|
||||
// .all
|
||||
boolResult = mm.all('foo.js', ['foo.js']);
|
||||
boolResult = mm.all(['foo.js', 'bar.js'], ['*.js', '!foo.js']);
|
||||
boolResult = mm.all(['foo.js', 'bar.js'], '*.js');
|
||||
|
||||
// "any" method.
|
||||
boolResult = mm.any('abc', ['!*z']);
|
||||
boolResult = mm.any('abc', 'a*');
|
||||
boolResult = mm.any('abc', 'a*', {dot: true});
|
||||
// .not
|
||||
strArrResult = mm.not(['a.a', 'b.b', 'c.c'], '*.a');
|
||||
|
||||
// "expand" method.
|
||||
globDataResult = mm.expand('*.js');
|
||||
globDataResult = mm.expand('*.js', {dot: true});
|
||||
// .contains
|
||||
boolResult = mm.contains('aa/bb/cc', '*b');
|
||||
boolResult = mm.contains('aa/bb/cc', ['*b', '*a']);
|
||||
|
||||
// "makeRe" method.
|
||||
regExpResult = mm.makeRe('*.js');
|
||||
regExpResult = mm.makeRe('*.js', {dot: true});
|
||||
// .matchKeys
|
||||
const obj = { aa: 'a', ab: 'b', ac: 'c' };
|
||||
const partialObj: Partial<typeof obj> = mm.matchKeys(obj, '*b');
|
||||
|
||||
// .matcher
|
||||
const matcherFn: (str: string) => boolean = mm.matcher('*.!(*a)');
|
||||
|
||||
// .capture
|
||||
const strArrResultNullable: string[] | null = mm.capture('test/*.js', 'test/foo.js');
|
||||
|
||||
// .makeRe
|
||||
const regex: RegExp = mm.makeRe('*.js');
|
||||
|
||||
// .braces
|
||||
strArrResult = mm.braces('*.js');
|
||||
strArrResult = mm.braces('*.js', { expand: true });
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
|
||||
@@ -1,79 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
}
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Vendored
+171
@@ -0,0 +1,171 @@
|
||||
// Type definitions for micromatch 2.3.7
|
||||
// Project: https://github.com/jonschlinkert/micromatch
|
||||
// Definitions by: glen-84 <https://github.com/glen-84>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
import parseGlob = require('parse-glob');
|
||||
|
||||
declare namespace micromatch {
|
||||
type MatchFunction<T> = ((value: T) => boolean);
|
||||
type Pattern = (string | RegExp | MatchFunction<string>);
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
* Normalize slashes in file paths and glob patterns to forward slashes.
|
||||
*/
|
||||
unixify?: boolean;
|
||||
/**
|
||||
* Match dotfiles. Same behavior as minimatch.
|
||||
*/
|
||||
dot?: boolean;
|
||||
/**
|
||||
* Unescape slashes in glob patterns. Use cautiously, especially on windows.
|
||||
*/
|
||||
unescape?: boolean;
|
||||
/**
|
||||
* Remove duplicate elements from the result array.
|
||||
*/
|
||||
nodupes?: boolean;
|
||||
/**
|
||||
* Allow glob patterns without slashes to match a file path based on its basename. Same behavior as
|
||||
* minimatch.
|
||||
*/
|
||||
matchBase?: boolean;
|
||||
/**
|
||||
* Don't expand braces in glob patterns. Same behavior as minimatch nobrace.
|
||||
*/
|
||||
nobraces?: boolean;
|
||||
/**
|
||||
* Don't expand POSIX bracket expressions.
|
||||
*/
|
||||
nobrackets?: boolean;
|
||||
/**
|
||||
* Don't expand extended globs.
|
||||
*/
|
||||
noextglob?: boolean;
|
||||
/**
|
||||
* Use a case-insensitive regex for matching files. Same behavior as minimatch.
|
||||
*/
|
||||
nocase?: boolean;
|
||||
/**
|
||||
* If true, when no matches are found the actual (array-ified) glob pattern is returned instead of an empty
|
||||
* array. Same behavior as minimatch.
|
||||
*/
|
||||
nonull?: boolean;
|
||||
/**
|
||||
* Cache the platform (e.g. win32) to prevent this from being looked up for every file path.
|
||||
*/
|
||||
cache?: boolean;
|
||||
}
|
||||
|
||||
interface Glob {
|
||||
options: micromatch.Options;
|
||||
pattern: string;
|
||||
history: { msg: any, pattern: string }[];
|
||||
tokens: parseGlob.Result;
|
||||
orig: string;
|
||||
negated: boolean;
|
||||
|
||||
/**
|
||||
* Initialize defaults.
|
||||
*/
|
||||
init(pattern: string): void;
|
||||
|
||||
/**
|
||||
* Push a change into `glob.history`. Useful for debugging.
|
||||
*/
|
||||
track(msg: any): void;
|
||||
|
||||
/**
|
||||
* Return true if `glob.pattern` was negated with `!`, also remove the `!` from the pattern.
|
||||
*/
|
||||
isNegated(): boolean;
|
||||
|
||||
/**
|
||||
* Expand braces in the given glob pattern.
|
||||
*/
|
||||
braces(): void;
|
||||
|
||||
/**
|
||||
* Expand bracket expressions in `glob.pattern`.
|
||||
*/
|
||||
brackets(): void;
|
||||
|
||||
/**
|
||||
* Expand extended globs in `glob.pattern`.
|
||||
*/
|
||||
extglob(): void;
|
||||
|
||||
/**
|
||||
* Parse the given pattern.
|
||||
*/
|
||||
parse(pattern: string): parseGlob.Result;
|
||||
|
||||
/**
|
||||
* Escape special characters in the given string.
|
||||
*/
|
||||
escape(pattern: string): string;
|
||||
|
||||
/**
|
||||
* Unescape special characters in the given string.
|
||||
*/
|
||||
unescape(pattern: string): string;
|
||||
}
|
||||
|
||||
interface GlobData {
|
||||
pattern: string;
|
||||
tokens: parseGlob.Result;
|
||||
options: micromatch.Options;
|
||||
}
|
||||
}
|
||||
|
||||
interface Micromatch {
|
||||
(files: string | string[], patterns: micromatch.Pattern | micromatch.Pattern[]): string[];
|
||||
|
||||
isMatch: {
|
||||
/**
|
||||
* Returns true if a file path matches the given pattern.
|
||||
*/
|
||||
(filePath: string, pattern: micromatch.Pattern, opts?: micromatch.Options): boolean;
|
||||
/**
|
||||
* Returns a function for matching.
|
||||
*/
|
||||
(filePath: string, opts?: micromatch.Options): micromatch.MatchFunction<string>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if any part of a file path matches the given pattern. Think of this as "has path" versus
|
||||
* "is path".
|
||||
*/
|
||||
contains(filePath: string, pattern: micromatch.Pattern, opts?: micromatch.Options): boolean;
|
||||
|
||||
/**
|
||||
* Returns a function for matching using the supplied pattern. e.g. create your own "matcher". The advantage of
|
||||
* this method is that the pattern can be compiled outside of a loop.
|
||||
*/
|
||||
matcher(pattern: micromatch.Pattern): micromatch.MatchFunction<string>;
|
||||
|
||||
/**
|
||||
* Returns a function that can be passed to Array#filter().
|
||||
*/
|
||||
filter(patterns: micromatch.Pattern | micromatch.Pattern[], opts?: micromatch.Options): micromatch.MatchFunction<any>;
|
||||
|
||||
/**
|
||||
* Returns true if a file path matches any of the given patterns.
|
||||
*/
|
||||
any(filePath: string, patterns: micromatch.Pattern | micromatch.Pattern[], opts?: micromatch.Options): boolean;
|
||||
|
||||
/**
|
||||
* Returns an object with a regex-compatible string and tokens.
|
||||
*/
|
||||
expand(pattern: string, opts?: micromatch.Options): micromatch.Glob | micromatch.GlobData;
|
||||
|
||||
/**
|
||||
* Create a regular expression for matching file paths based on the given pattern.
|
||||
*/
|
||||
makeRe(pattern: string, opts?: micromatch.Options): RegExp;
|
||||
}
|
||||
|
||||
declare const micromatch: Micromatch;
|
||||
export = micromatch;
|
||||
@@ -0,0 +1,54 @@
|
||||
|
||||
import mm = require('micromatch');
|
||||
|
||||
var strArrResult: string[];
|
||||
var boolResult: boolean;
|
||||
var strMatchFuncResult: mm.MatchFunction<string>;
|
||||
var anyMatchFuncResult: mm.MatchFunction<any>;
|
||||
var globDataResult: mm.GlobData;
|
||||
var regExpResult: RegExp;
|
||||
|
||||
// Usage.
|
||||
strArrResult = mm(['a.js', 'b.md', 'c.txt'], '*.{js,txt}');
|
||||
|
||||
// Multiple patterns.
|
||||
strArrResult = mm(['a.md', 'b.js', 'c.txt', 'd.json'], ['*.md', '*.txt']);
|
||||
|
||||
// "isMatch" method.
|
||||
boolResult = mm.isMatch('.verb.md', '*.md');
|
||||
boolResult = mm.isMatch('.verb.md', '*.md', {dot: true});
|
||||
boolResult = mm.isMatch('*.md', {dot: true})('.verb.md');
|
||||
|
||||
// "contains" method.
|
||||
boolResult = mm.contains('a/b/c', 'a/b');
|
||||
boolResult = mm.contains('a/b/c', 'a/b', {dot: true});
|
||||
|
||||
// "matcher" method.
|
||||
strMatchFuncResult = mm.matcher('*.md');
|
||||
strMatchFuncResult = mm.matcher(/\.md$/);
|
||||
strMatchFuncResult = mm.matcher((filePath: string) => true);
|
||||
|
||||
// "filter" method.
|
||||
anyMatchFuncResult = mm.filter('*.md');
|
||||
anyMatchFuncResult = mm.filter(/\.md$/);
|
||||
anyMatchFuncResult = mm.filter((filePath: string) => true);
|
||||
|
||||
anyMatchFuncResult = mm.filter('*.md', {dot: true});
|
||||
['a.js', 'b.txt', 'c.md'].filter(anyMatchFuncResult);
|
||||
|
||||
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
|
||||
anyMatchFuncResult = mm.filter(['{1..10}', '![7-9]', '!{3..4}']);
|
||||
arr.filter(anyMatchFuncResult);
|
||||
|
||||
// "any" method.
|
||||
boolResult = mm.any('abc', ['!*z']);
|
||||
boolResult = mm.any('abc', 'a*');
|
||||
boolResult = mm.any('abc', 'a*', {dot: true});
|
||||
|
||||
// "expand" method.
|
||||
globDataResult = mm.expand('*.js');
|
||||
globDataResult = mm.expand('*.js', {dot: true});
|
||||
|
||||
// "makeRe" method.
|
||||
regExpResult = mm.makeRe('*.js');
|
||||
regExpResult = mm.makeRe('*.js', {dot: true});
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../../",
|
||||
"paths": {
|
||||
"micromatch": [
|
||||
"micromatch/v2"
|
||||
]
|
||||
},
|
||||
"typeRoots": [
|
||||
"../../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"micromatch-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user