ac336c5cf5
* fixing audit failures * replacing lerna bootstrap with npm command * audit fix for cache and tool-cache * updating tunnel * upgrading core packages * re-adding tunnel as prod dep * updating dependencies * updating exec deps * updating exec io package * . * Revert * updating packages * adding core as dep * updating learna config * updating lerna commands * Removing audit failing packages in cache + tool-cache * updating contribution bootstrap description * updating libraries * prettier lint * hiding stricter rules * updating prettier command * Removing unknown flag * Adding eslint prettier * ignoring sym links * updating ignore path * updating prettier rules * changing prettier + github ver * updating ts and ignores * Revert ts * Adding unknown ignores * downgrading lerna * . * adding nx * Adding lint auto lint rules * updating eslint ignore for glob packages * Adding subdirs to ignore * adding flag for ignore pattern in linter * Expanding ignore regex * Adding ignore rules * adding another ignore pattern to tsconfig eslint * adding ignore pattern to eslintrc * syncing package-json * updating traverse * . * test adding core and http client to base package * running npm ci * adding tsconfig paths * adding base URL * Adding explicit path to core and http-client * editing tsc call * updating artifact packages * force build * updating lock file version * updating lock file version * upgrading node version * Adding babel traverse back * fixing build issue * fixing typescript ver * updating package json * Adding ignore for artifact test * adding ignore to flags * unlink after test completes * cleanup * merge + package edit |
||
---|---|---|
.. | ||
__tests__ | ||
src | ||
LICENSE.md | ||
README.md | ||
RELEASES.md | ||
package-lock.json | ||
package.json | ||
tsconfig.json |
README.md
@actions/glob
Usage
Basic
You can use this package to search for files matching glob patterns.
Relative paths and absolute paths are both allowed. Relative paths are rooted against the current working directory.
const glob = require('@actions/glob');
const patterns = ['**/tar.gz', '**/tar.bz']
const globber = await glob.create(patterns.join('\n'))
const files = await globber.glob()
Opt out of following symbolic links
const glob = require('@actions/glob');
const globber = await glob.create('**', {followSymbolicLinks: false})
const files = await globber.glob()
Iterator
When dealing with a large amount of results, consider iterating the results as they are returned:
const glob = require('@actions/glob');
const globber = await glob.create('**')
for await (const file of globber.globGenerator()) {
console.log(file)
}
Recommended action inputs
Glob follows symbolic links by default. Following is often appropriate unless deleting files.
Users may want to opt-out from following symbolic links for other reasons. For example, excessive amounts of symbolic links can create the appearance of very, very many files and slow the search.
When an action allows a user to specify input patterns, it is generally recommended to allow users to opt-out from following symbolic links.
Snippet from action.yml
:
inputs:
files:
description: 'Files to print'
required: true
follow-symbolic-links:
description: 'Indicates whether to follow symbolic links'
default: true
And corresponding toolkit consumption:
const core = require('@actions/core')
const glob = require('@actions/glob')
const globOptions = {
followSymbolicLinks: core.getInput('follow-symbolic-links').toUpper() !== 'FALSE'
}
const globber = glob.create(core.getInput('files'), globOptions)
for await (const file of globber.globGenerator()) {
console.log(file)
}
Patterns
Glob behavior
Patterns *
, ?
, [...]
, **
(globstar) are supported.
With the following behaviors:
- File names that begin with
.
may be included in the results - Case insensitive on Windows
- Directory separator
/
and\
both supported on Windows
Tilde expansion
Supports basic tilde expansion, for current user HOME replacement only.
Example:
~
may expand to /Users/johndoe~/foo
may expand to /Users/johndoe/foo
Comments
Patterns that begin with #
are treated as comments.
Exclude patterns
Leading !
changes the meaning of an include pattern to exclude.
Multiple leading !
flips the meaning.
Escaping
Wrapping special characters in []
can be used to escape literal glob characters
in a file name. For example the literal file name hello[a-z]
can be escaped as hello[[]a-z]
.
On Linux/macOS \
is also treated as an escape character.