feat(globby): add typings for globby

This commit is contained in:
Douglas Duteil
2017-06-28 11:18:37 +02:00
committed by GitHub
parent 09c31b3084
commit cd8e349fe7
4 changed files with 67 additions and 0 deletions

View 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
View 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;

View 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
View File

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