mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-15 22:34:55 +08:00
feat(globby): add typings for globby
This commit is contained in:
27
types/globby/globby-tests.ts
Normal file
27
types/globby/globby-tests.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
//
|
||||
|
||||
import { IOptions } from 'glob';
|
||||
|
||||
import * as globby from "globby";
|
||||
|
||||
(async () => {
|
||||
let result: string[];
|
||||
result = await globby('*.tmp')
|
||||
result = await globby(['a.tmp', '*.tmp', '!{c,d,e}.tmp'])
|
||||
|
||||
result = globby.sync('*.tmp')
|
||||
result = globby.sync(['a.tmp', '*.tmp', '!{c,d,e}.tmp'])
|
||||
|
||||
result = await globby('*.tmp', Object.freeze({ignore: Object.freeze([])}))
|
||||
result = globby.sync('*.tmp', Object.freeze({ignore: Object.freeze([])}))
|
||||
})()
|
||||
|
||||
|
||||
const tasks: Array<{
|
||||
pattern: string,
|
||||
options: IOptions
|
||||
}> = globby.generateGlobTasks(['*.tmp', '!b.tmp'], {ignore: ['c.tmp']});
|
||||
|
||||
console.log(globby.hasMagic('**') === true);
|
||||
console.log(globby.hasMagic(['**', 'path1', 'path2']) === true);
|
||||
console.log(globby.hasMagic(['path1', 'path2']) === false);
|
||||
17
types/globby/index.d.ts
vendored
Normal file
17
types/globby/index.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
// Type definitions for globby 0.6
|
||||
// Project: https://github.com/sindresorhus/globby#readme
|
||||
// Definitions by: Douglas Duteil <https://github.com/douglasduteil>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { IOptions } from 'glob';
|
||||
|
||||
declare function globby(patterns: string | string[], options?: Partial<IOptions>): Promise<string[]>;
|
||||
|
||||
declare namespace globby {
|
||||
function sync(patterns: string | string[], options?: Partial<IOptions>): string[];
|
||||
function generateGlobTasks(patterns: string | string[], options?: Partial<IOptions>): Array<{pattern: string, options: IOptions}>;
|
||||
function hasMagic(patterns: string | string[], options?: Partial<IOptions>): boolean;
|
||||
}
|
||||
|
||||
export = globby;
|
||||
22
types/globby/tsconfig.json
Normal file
22
types/globby/tsconfig.json
Normal file
@@ -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",
|
||||
"globby-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/globby/tslint.json
Normal file
1
types/globby/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user