Merge pull request #17566 from douglasduteil/feat-globby-add-typings-for-globby

feat(globby): add typings for `globby`
This commit is contained in:
Paul van Brenk
2017-06-28 11:13:00 -07:00
committed by GitHub
4 changed files with 64 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
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
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?: IOptions): Promise<string[]>;
declare namespace globby {
function sync(patterns: string | string[], options?: IOptions): string[];
function generateGlobTasks(patterns: string | string[], options?: IOptions): Array<{pattern: string, options: IOptions}>;
function hasMagic(patterns: string | string[], options?: IOptions): boolean;
}
export = globby;
+22
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
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }