mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-01 00:03:17 +08:00
Add directory filtering to globber (#728)
Co-authored-by: Thomas Boop <52323235+thboop@users.noreply.github.com>
This commit is contained in:
@@ -8,6 +8,7 @@ export function getOptions(copy?: GlobOptions): GlobOptions {
|
||||
const result: GlobOptions = {
|
||||
followSymbolicLinks: true,
|
||||
implicitDescendants: true,
|
||||
matchDirectories: true,
|
||||
omitBrokenSymbolicLinks: true
|
||||
}
|
||||
|
||||
@@ -22,6 +23,11 @@ export function getOptions(copy?: GlobOptions): GlobOptions {
|
||||
core.debug(`implicitDescendants '${result.implicitDescendants}'`)
|
||||
}
|
||||
|
||||
if (typeof copy.matchDirectories === 'boolean') {
|
||||
result.matchDirectories = copy.matchDirectories
|
||||
core.debug(`matchDirectories '${result.matchDirectories}'`)
|
||||
}
|
||||
|
||||
if (typeof copy.omitBrokenSymbolicLinks === 'boolean') {
|
||||
result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks
|
||||
core.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`)
|
||||
|
||||
@@ -21,6 +21,14 @@ export interface GlobOptions {
|
||||
*/
|
||||
implicitDescendants?: boolean
|
||||
|
||||
/**
|
||||
* Indicates whether matching directories should be included in the
|
||||
* result set.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
matchDirectories?: boolean
|
||||
|
||||
/**
|
||||
* Indicates whether broken symbolic should be ignored and omitted from the
|
||||
* result set. Otherwise an error will be thrown.
|
||||
|
||||
@@ -131,7 +131,7 @@ export class DefaultGlobber implements Globber {
|
||||
// Directory
|
||||
if (stats.isDirectory()) {
|
||||
// Matched
|
||||
if (match & MatchKind.Directory) {
|
||||
if (match & MatchKind.Directory && options.matchDirectories) {
|
||||
yield item.path
|
||||
}
|
||||
// Descend?
|
||||
|
||||
Reference in New Issue
Block a user