From ed379ea45edd01b71d754f9d3e808f7da8980ce6 Mon Sep 17 00:00:00 2001 From: Toke Voltelen Date: Fri, 6 Apr 2018 11:43:09 +0200 Subject: [PATCH 01/17] Add paths util --- src/index.ts | 1 + src/lib/utils/paths.ts | 17 +++++++++++ src/test/renderer/specs/index.html | 2 ++ src/test/utils.paths.ts | 47 ++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 src/lib/utils/paths.ts create mode 100644 src/test/utils.paths.ts diff --git a/src/index.ts b/src/index.ts index a1c3ca875..7241c7b66 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,6 +2,7 @@ export { Application } from './lib/application'; export { CliApplication } from './lib/cli'; export { EventDispatcher, Event } from './lib/utils/events'; +export { pathToMinimatch } from './lib/utils/paths'; export { resetReflectionID } from './lib/models/reflections/abstract'; export { normalizePath } from './lib/utils/fs'; export * from './lib/models/reflections'; diff --git a/src/lib/utils/paths.ts b/src/lib/utils/paths.ts new file mode 100644 index 000000000..a93984833 --- /dev/null +++ b/src/lib/utils/paths.ts @@ -0,0 +1,17 @@ +import * as Path from 'path'; +import { isArray } from 'util'; +import { Minimatch, IMinimatch } from 'minimatch'; + +function createMinimatch(pattern: string): IMinimatch { + if (pattern[0] === '.' || /^\w+(?!:)($|[/\\])/.test(pattern)) { + pattern = Path.resolve(pattern); + } + + return new Minimatch(pattern, { dot: true }); +} + +export function pathToMinimatch(pattern: string | string[]): IMinimatch | IMinimatch[] { + return isArray(pattern) + ? pattern.map(createMinimatch) + : createMinimatch(pattern); +} diff --git a/src/test/renderer/specs/index.html b/src/test/renderer/specs/index.html index 37e333b0d..c0173c72f 100644 --- a/src/test/renderer/specs/index.html +++ b/src/test/renderer/specs/index.html @@ -127,6 +127,8 @@

TypeScript compiler

Specify module code generation: "commonjs", "amd", "system" or "umd".
  • --target <ES3, ES5, or ES6>
    Specify ECMAScript target version: "ES3" (default), "ES5" or "ES6"
  • +
  • --tsconfig <path/to/tsconfig.json>
    + Specify a typescript config file that should be loaded. If not specified TypeDoc will look for 'tsconfig.json' in the current directory.
  • Theming