diff --git a/types/glob/v5/glob-tests.ts b/types/glob/v5/glob-tests.ts new file mode 100644 index 0000000000..e0f612e682 --- /dev/null +++ b/types/glob/v5/glob-tests.ts @@ -0,0 +1,30 @@ +import glob = require("glob"); +const Glob = glob.Glob; + +(() => { + const pattern = "test/a/**/[cg]/../[cg]"; + console.log(pattern); + + const mg = new Glob(pattern, {mark: true, sync: true}, (er, matches) => { + if (er) { + console.error(er); + return; + } + console.log("matches", matches); + }); + console.log("after"); +})(); + +(() => { + const pattern = "{./*/*,/*,/usr/local/*}"; + console.log(pattern); + + const mg = new Glob(pattern, {mark: true}, (er, matches) => { + if (er) { + console.error(er); + return; + } + console.log("matches", matches); + }); + console.log("after"); +})(); diff --git a/types/glob/v5/index.d.ts b/types/glob/v5/index.d.ts new file mode 100644 index 0000000000..92c2532e79 --- /dev/null +++ b/types/glob/v5/index.d.ts @@ -0,0 +1,112 @@ +// Type definitions for Glob 5.0 +// Project: https://github.com/isaacs/node-glob +// Definitions by: vvakame +// voy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import events = require("events"); +import fs = require('fs'); +import minimatch = require("minimatch"); + +declare function G(pattern: string, cb: (err: Error | null, matches: string[]) => void): void; +declare function G(pattern: string, options: G.IOptions, cb: (err: Error | null, matches: string[]) => void): void; + +declare namespace G { + function __promisify__(pattern: string, options?: IOptions): Promise; + + function sync(pattern: string, options?: IOptions): string[]; + + function hasMagic(pattern: string, options?: IOptions): boolean; + + let Glob: IGlobStatic; + let GlobSync: IGlobSyncStatic; + + interface IOptions extends minimatch.IOptions { + cwd?: string; + root?: string; + dot?: boolean; + nomount?: boolean; + mark?: boolean; + nosort?: boolean; + stat?: boolean; + silent?: boolean; + strict?: boolean; + cache?: { [path: string]: any /* boolean | string | string[] */ }; + statCache?: { [path: string]: fs.Stats }; + symlinks?: any; + sync?: boolean; + nounique?: boolean; + nonull?: boolean; + debug?: boolean; + nobrace?: boolean; + noglobstar?: boolean; + noext?: boolean; + nocase?: boolean; + matchBase?: any; + nodir?: boolean; + ignore?: any; /* string | string[] */ + follow?: boolean; + realpath?: boolean; + nonegate?: boolean; + nocomment?: boolean; + absolute?: boolean; + + /** Deprecated. */ + globDebug?: boolean; + } + + interface IGlobStatic extends events.EventEmitter { + new (pattern: string, cb?: (err: Error | null, matches: string[]) => void): IGlob; + new (pattern: string, options: IOptions, cb?: (err: Error | null, matches: string[]) => void): IGlob; + prototype: IGlob; + } + + interface IGlobSyncStatic { + new (pattern: string, options?: IOptions): IGlobBase; + prototype: IGlobBase; + } + + interface IGlobBase { + minimatch: minimatch.IMinimatch; + options: IOptions; + aborted: boolean; + cache: { [path: string]: any /* boolean | string | string[] */ }; + statCache: { [path: string]: fs.Stats }; + symlinks: { [path: string]: boolean }; + realpathCache: { [path: string]: string }; + found: string[]; + } + + interface IGlob extends IGlobBase, events.EventEmitter { + pause(): void; + resume(): void; + abort(): void; + + /** Deprecated. */ + EOF: any; + /** Deprecated. */ + paused: boolean; + /** Deprecated. */ + maxDepth: number; + /** Deprecated. */ + maxLength: number; + /** Deprecated. */ + changedCwd: boolean; + /** Deprecated. */ + cwd: string; + /** Deprecated. */ + root: string; + /** Deprecated. */ + error: any; + /** Deprecated. */ + matches: string[]; + /** Deprecated. */ + log(...args: any[]): void; + /** Deprecated. */ + emitMatch(m: any): void; + } +} + +export = G; diff --git a/types/glob/v5/tsconfig.json b/types/glob/v5/tsconfig.json new file mode 100644 index 0000000000..2fcd908b6a --- /dev/null +++ b/types/glob/v5/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "glob-tests.ts" + ] +} diff --git a/types/glob/v5/tslint.json b/types/glob/v5/tslint.json new file mode 100644 index 0000000000..2c7c1bed53 --- /dev/null +++ b/types/glob/v5/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "interface-name": false + } +}