mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-24 03:48:03 +08:00
multiple glob patterns (#287)
This commit is contained in:
@@ -1,41 +1,9 @@
|
||||
import * as core from '@actions/core'
|
||||
import * as pathHelper from './internal-path-helper'
|
||||
import {IGlobOptions} from './internal-glob-options'
|
||||
import {MatchKind} from './internal-match-kind'
|
||||
import {Pattern} from './internal-pattern'
|
||||
|
||||
const IS_WINDOWS = process.platform === 'win32'
|
||||
|
||||
/**
|
||||
* Returns a copy with defaults filled in
|
||||
*/
|
||||
export function getOptions(copy?: IGlobOptions): IGlobOptions {
|
||||
const result: IGlobOptions = {
|
||||
followSymbolicLinks: true,
|
||||
implicitDescendants: true,
|
||||
omitBrokenSymbolicLinks: true
|
||||
}
|
||||
|
||||
if (copy) {
|
||||
if (typeof copy.followSymbolicLinks === 'boolean') {
|
||||
result.followSymbolicLinks = copy.followSymbolicLinks
|
||||
core.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`)
|
||||
}
|
||||
|
||||
if (typeof copy.implicitDescendants === 'boolean') {
|
||||
result.implicitDescendants = copy.implicitDescendants
|
||||
core.debug(`implicitDescendants '${result.implicitDescendants}'`)
|
||||
}
|
||||
|
||||
if (typeof copy.omitBrokenSymbolicLinks === 'boolean') {
|
||||
result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks
|
||||
core.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an array of patterns, returns an array of paths to search.
|
||||
* Duplicates and paths under other included paths are filtered out.
|
||||
@@ -105,36 +73,6 @@ export function match(patterns: Pattern[], itemPath: string): MatchKind {
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the pattern strings into Pattern objects
|
||||
*/
|
||||
export function parse(patterns: string[], options: IGlobOptions): Pattern[] {
|
||||
const result: Pattern[] = []
|
||||
|
||||
for (const patternString of patterns.map(x => x.trim())) {
|
||||
// Skip empty or comment
|
||||
if (!patternString || patternString.startsWith('#')) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Push
|
||||
const pattern = new Pattern(patternString)
|
||||
result.push(pattern)
|
||||
|
||||
// Implicit descendants?
|
||||
if (
|
||||
options.implicitDescendants &&
|
||||
(pattern.trailingSeparator ||
|
||||
pattern.segments[pattern.segments.length - 1] !== '**')
|
||||
) {
|
||||
// Push
|
||||
result.push(new Pattern(pattern.negate, pattern.segments.concat('**')))
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether to descend further into the directory
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user