add glob-expand

This commit is contained in:
vvakame 2015-10-14 21:11:50 +09:00
parent b27d0d0e1c
commit 7283a45802
2 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,22 @@
/// <reference path="./glob-expand.d.ts" />
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'

27
glob-expand/glob-expand.d.ts vendored Normal file
View File

@ -0,0 +1,27 @@
// Type definitions for glob-expand
// Project: https://github.com/anodynos/node-glob-expand
// Definitions by: vvakame <https://github.com/vvakame/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../glob/glob.d.ts" />
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;
}