Comparing version 2.1.0 to 2.2.0
# master | ||
# 2.2.0 | ||
* add globOptions to provide the capability to configure string globs with all minimatch options passed to `globs` and `ignored` | ||
# 2.1.0 | ||
@@ -4,0 +8,0 @@ |
/// <reference types="node" /> | ||
import fsNode = require('fs'); | ||
import { IMinimatch } from 'minimatch'; | ||
import { IMinimatch, IOptions as MinimatchOptions } from 'minimatch'; | ||
declare type Optionalize<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>; | ||
@@ -15,2 +15,3 @@ declare function walkSync(baseDir: string, inputOptions?: Optionalize<walkSync.Options, 'fs'> | (string | IMinimatch)[]): string[]; | ||
fs: typeof fsNode; | ||
globOptions?: MinimatchOptions; | ||
} | ||
@@ -17,0 +18,0 @@ class Entry { |
14
index.js
@@ -6,2 +6,3 @@ 'use strict'; | ||
const path = require("path"); | ||
const minimatch_1 = require("minimatch"); | ||
function walkSync(baseDir, inputOptions) { | ||
@@ -72,2 +73,10 @@ const options = handleOptions(inputOptions); | ||
} | ||
function applyGlobOptions(globs, options) { | ||
return globs === null || globs === void 0 ? void 0 : globs.map(glob => { | ||
if (typeof glob === 'string') { | ||
return new minimatch_1.Minimatch(glob, options); | ||
} | ||
return glob; | ||
}); | ||
} | ||
function handleRelativePath(_relativePath) { | ||
@@ -110,4 +119,5 @@ if (_relativePath == null) { | ||
try { | ||
const globs = options.globs; | ||
const ignorePatterns = options.ignore; | ||
const globOptions = options.globOptions; | ||
const ignorePatterns = (isDefined(globOptions)) ? applyGlobOptions(options.ignore, globOptions) : options.ignore; | ||
const globs = (isDefined(globOptions)) ? applyGlobOptions(options.globs, globOptions) : options.globs; | ||
let globMatcher; | ||
@@ -114,0 +124,0 @@ let ignoreMatcher; |
{ | ||
"name": "walk-sync", | ||
"description": "Get an array of recursive directory contents", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"author": "Jo Liss <joliss42@gmail.com>", | ||
@@ -23,3 +23,4 @@ "main": "index.js", | ||
"ensure-posix-path": "^1.1.0", | ||
"matcher-collection": "^2.0.0" | ||
"matcher-collection": "^2.0.0", | ||
"minimatch": "^3.0.4" | ||
}, | ||
@@ -26,0 +27,0 @@ "devDependencies": { |
@@ -90,2 +90,6 @@ # node-walk-sync | ||
As an alternative to string globs, you can pass an array of precompiled | ||
[`minimatch.Minimatch`](https://github.com/isaacs/minimatch#minimatch-class) | ||
instances. This is faster and allows to specify your own globbing options. | ||
* `includeBasePath` (default: false): Pass `true` to include the basePath in the output. | ||
@@ -108,2 +112,6 @@ *note: this flag is only for `walkSync(..)` not `walkSync.entries(..)`* | ||
``` | ||
* `globOptions`: Pass any options for [Minimatch](https://www.npmjs.com/package/minimatch) that will be applied to all items in `globs` and `ignore` that are strings. | ||
If items in `globs` or `ignore` are instances of `minimatch.Minimatch`, the `globOptions` will not be applied. | ||
@@ -110,0 +118,0 @@ ## Background |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14630
195
128
4
+ Addedminimatch@^3.0.4