From 7283a45802e9f7d79c88c571ec013a9d982f7202 Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 14 Oct 2015 21:11:50 +0900 Subject: [PATCH] add glob-expand --- glob-expand/glob-expand-tests.ts | 22 ++++++++++++++++++++++ glob-expand/glob-expand.d.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 glob-expand/glob-expand-tests.ts create mode 100644 glob-expand/glob-expand.d.ts diff --git a/glob-expand/glob-expand-tests.ts b/glob-expand/glob-expand-tests.ts new file mode 100644 index 000000000..fc17e5fea --- /dev/null +++ b/glob-expand/glob-expand-tests.ts @@ -0,0 +1,22 @@ +/// + +import * as expand from "glob-expand"; + +expand({ filter: 'isFile', cwd: '../' }, ['**/*.*', '!exclude/these/**/*.*']); +// returns all files in cwd ['file1', 'file2',...] but excluding +// those under directory 'exclude/these' + +// These are the same +expand({ cwd: '../..' }, ['**/*.*', '!node_modules/**/*.*']); +expand({ cwd: '../..' }, '**/*.*', '!node_modules/**/*.*'); + +// These are the same too: +expand({}, ['**/*.*', '!**/*.js']); +expand({}, '**/*.*', '!**/*.js'); +expand(['**/*.*', '!**/*.js']); +expand('**/*.*', '!**/*.js'); + +// Using Regular Expressions: +expand('**/*.js', /.*\.(coffee\.md|litcoffee|coffee)$/i, '!DRAFT*.*'); +// -> returns all `.js`, `.coffee`, `.coffee.md` & `.litcoffee` files, +// excluding those starting with 'DRAFT' diff --git a/glob-expand/glob-expand.d.ts b/glob-expand/glob-expand.d.ts new file mode 100644 index 000000000..0e1258279 --- /dev/null +++ b/glob-expand/glob-expand.d.ts @@ -0,0 +1,27 @@ +// Type definitions for glob-expand +// Project: https://github.com/anodynos/node-glob-expand +// Definitions by: vvakame +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "glob-expand" { + import * as _glob from "glob"; + + interface Option { + filter?: string | ((filePath: string) => boolean); + cwd?: string; + } + + module expand { + var glob: typeof _glob; + var VERSION: string; + } + + function expand(opts: Option, patterns: (string | RegExp)[]): string[]; + function expand(opts: Option, ...patterns: (string | RegExp)[]): string[]; + function expand(patterns: (string | RegExp)[]): string[]; + function expand(...patterns: (string | RegExp)[]): string[]; + + export = expand; +}