mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Added definition for globule (#14153)
* Implemented match, isMath and find * Added all functions * Made options optional. * Added tslint.json and fixed lint errors * Fixed definition for mapping function * Fixed issue with strict nulls
This commit is contained in:
parent
a5a560b3e1
commit
138e095da4
28
globule/globule-tests.ts
Normal file
28
globule/globule-tests.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import * as globule from 'globule';
|
||||
|
||||
let filepaths: string[];
|
||||
|
||||
filepaths = globule.find('**/*.js');
|
||||
filepaths = globule.find(['**/*.js']);
|
||||
filepaths = globule.find('**/*.js', '**/*.less');
|
||||
filepaths = globule.find('*.js', { matchBase: true });
|
||||
filepaths = globule.find('**/*.js', '**/*.less', { filter: 'isFile' });
|
||||
filepaths = globule.find('**/*.js', '**/*.less', { filter: /jQuery/i.test });
|
||||
filepaths = globule.find({ src: '**/*.js' });
|
||||
|
||||
filepaths = globule.match('*.js', '/home/code');
|
||||
filepaths = globule.match('*.js', '/home/code', { matchBase: true });
|
||||
|
||||
let bResult: boolean;
|
||||
bResult = globule.isMatch('*.js', '/home/code');
|
||||
bResult = globule.isMatch('*.js', '/home/code', { matchBase: true });
|
||||
|
||||
let mappings = globule.mapping(['*.js']);
|
||||
let len = mappings.length;
|
||||
let src = mappings[0].src;
|
||||
let dest = mappings[0].dest;
|
||||
|
||||
mappings = globule.mapping(['*.js'], { srcBase: '/home/code' });
|
||||
mappings = globule.mapping(['*.js', '*.less']);
|
||||
mappings = globule.mapping(['*.js'], ['*.less']);
|
||||
|
||||
87
globule/index.d.ts
vendored
Normal file
87
globule/index.d.ts
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
// Type definitions for globule 1.1
|
||||
// Project: https://github.com/cowboy/node-globule
|
||||
// Definitions by: Dusan Radovanovic <https://github.com/durad>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import minimatch = require('minimatch');
|
||||
import glob = require('glob');
|
||||
|
||||
interface FindOptions extends glob.IOptions {
|
||||
src?: string;
|
||||
filter?: string | ((filepath?: string, options?: any) => boolean);
|
||||
nonull?: boolean;
|
||||
matchBase?: boolean;
|
||||
srcBase?: string;
|
||||
prefixBase?: boolean;
|
||||
}
|
||||
|
||||
interface MappingOptions extends FindOptions {
|
||||
srcBase?: string;
|
||||
destBase?: string;
|
||||
ext?: string;
|
||||
extDot?: 'first' | 'last';
|
||||
flatten?: boolean;
|
||||
rename?: (p: string) => string;
|
||||
}
|
||||
|
||||
interface OneMapping {
|
||||
src: string[];
|
||||
dest: string;
|
||||
}
|
||||
|
||||
interface GlobuleStatic {
|
||||
/**
|
||||
* Match one or more globbing patterns against one or more file paths.
|
||||
* Returns a uniqued array of all file paths that match any of the specified globbing patterns.
|
||||
*/
|
||||
match(patterns: string | string[], filepaths: string | string[], options?: minimatch.IOptions): string[];
|
||||
|
||||
/**
|
||||
* Tests pattern(s) against against one or more file paths and returns true if any files were matched, otherwise false.
|
||||
*/
|
||||
isMatch(patterns: string | string[], filepaths: string | string[], options?: minimatch.IOptions): boolean;
|
||||
|
||||
/**
|
||||
* Returns a unique array of all file or directory paths that match the given globbing pattern(s)
|
||||
*/
|
||||
find(pattern: string | string[], options?: FindOptions): string[];
|
||||
|
||||
/**
|
||||
* Returns a unique array of all file or directory paths that match the given globbing pattern(s)
|
||||
*/
|
||||
find(options: FindOptions): string[];
|
||||
|
||||
/**
|
||||
* Returns a unique array of all file or directory paths that match the given globbing pattern(s)
|
||||
*/
|
||||
find(pattern: string | string[], pattern2: string | string[], options?: FindOptions): string[];
|
||||
|
||||
/**
|
||||
* Returns a unique array of all file or directory paths that match the given globbing pattern(s)
|
||||
*/
|
||||
find(pattern: string, pattern2: string, pattern3: string | string[], options?: FindOptions): string[];
|
||||
|
||||
/**
|
||||
* Given a set of source file paths, returns an array of src-dest file mapping objects
|
||||
*/
|
||||
mapping(filepaths: string[], options?: MappingOptions): OneMapping[];
|
||||
|
||||
/**
|
||||
* Given a set of source file paths, returns an array of src-dest file mapping objects
|
||||
*/
|
||||
mapping(options: MappingOptions): OneMapping[];
|
||||
|
||||
/**
|
||||
* Given a set of source file paths, returns an array of src-dest file mapping objects
|
||||
*/
|
||||
mapping(filepaths: string[], filepaths2: string[], options?: MappingOptions): OneMapping[];
|
||||
|
||||
/**
|
||||
* Given a set of source file paths, returns an array of src-dest file mapping objects
|
||||
*/
|
||||
mapping(filepaths: string[], filepaths2: string[], filepaths3: string[], options?: MappingOptions): OneMapping[];
|
||||
}
|
||||
|
||||
declare var globule: GlobuleStatic;
|
||||
export = globule;
|
||||
|
||||
20
globule/tsconfig.json
Normal file
20
globule/tsconfig.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"globule-tests.ts"
|
||||
]
|
||||
}
|
||||
1
globule/tslint.json
Normal file
1
globule/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Loading…
Reference in New Issue
Block a user