Skip to content

Commit 284e083

Browse files
committed
Referenced glob files directly
Applied the fix from actions/toolkit#2154 and referenced the files directly
1 parent 1a3c14e commit 284e083

17 files changed

+1245
-14
lines changed

package-lock.json

Lines changed: 9 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,22 @@
4646
"@actions/cache": "^4.0.3",
4747
"@actions/core": "^1.11.1",
4848
"@actions/exec": "^1.1.1",
49-
"@actions/glob": "^0.5.0",
5049
"@actions/io": "^1.1.3",
5150
"@actions/tool-cache": "^2.0.2",
5251
"@types/semver": "^7.7.0",
52+
"minimatch": "^3.0.4",
5353
"semver": "^7.7.2"
5454
},
5555
"devDependencies": {
5656
"@eslint/compat": "^1.2.9",
5757
"@github/local-action": "^3.2.1",
5858
"@jest/globals": "^29.7.0",
5959
"@rollup/plugin-commonjs": "^28.0.1",
60+
"@rollup/plugin-json": "^6.1.0",
6061
"@rollup/plugin-node-resolve": "^16.0.1",
6162
"@rollup/plugin-typescript": "^12.1.1",
62-
"@rollup/plugin-json": "^6.1.0",
6363
"@types/jest": "^29.5.14",
64+
"@types/minimatch": "^5.1.2",
6465
"@types/node": "^20.17.48",
6566
"@typescript-eslint/eslint-plugin": "^8.32.1",
6667
"@typescript-eslint/parser": "^8.32.1",

src/actions-glob-temp/glob.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Globber, DefaultGlobber } from './internal-globber.js'
2+
import { GlobOptions } from './internal-glob-options.js'
3+
import { HashFileOptions } from './internal-hash-file-options.js'
4+
import { hashFiles as _hashFiles } from './internal-hash-files.js'
5+
6+
export { Globber, GlobOptions }
7+
8+
/**
9+
* Constructs a globber
10+
*
11+
* @param patterns Patterns separated by newlines
12+
* @param options Glob options
13+
*/
14+
export async function create(
15+
patterns: string,
16+
options?: GlobOptions
17+
): Promise<Globber> {
18+
return await DefaultGlobber.create(patterns, options)
19+
}
20+
21+
/**
22+
* Computes the sha256 hash of a glob
23+
*
24+
* @param patterns Patterns separated by newlines
25+
* @param currentWorkspace Workspace used when matching files
26+
* @param options Glob options
27+
* @param verbose Enables verbose logging
28+
*/
29+
export async function hashFiles(
30+
patterns: string,
31+
currentWorkspace = '',
32+
options?: HashFileOptions,
33+
verbose: boolean = false
34+
): Promise<string> {
35+
let followSymbolicLinks = true
36+
if (options && typeof options.followSymbolicLinks === 'boolean') {
37+
followSymbolicLinks = options.followSymbolicLinks
38+
}
39+
const globber = await create(patterns, { followSymbolicLinks })
40+
return _hashFiles(globber, currentWorkspace, verbose)
41+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import * as core from '@actions/core'
2+
import { GlobOptions } from './internal-glob-options.js'
3+
4+
/**
5+
* Returns a copy with defaults filled in.
6+
*/
7+
export function getOptions(copy?: GlobOptions): GlobOptions {
8+
const result: GlobOptions = {
9+
followSymbolicLinks: true,
10+
implicitDescendants: true,
11+
matchDirectories: true,
12+
omitBrokenSymbolicLinks: true,
13+
excludeHiddenFiles: false
14+
}
15+
16+
if (copy) {
17+
if (typeof copy.followSymbolicLinks === 'boolean') {
18+
result.followSymbolicLinks = copy.followSymbolicLinks
19+
core.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`)
20+
}
21+
22+
if (typeof copy.implicitDescendants === 'boolean') {
23+
result.implicitDescendants = copy.implicitDescendants
24+
core.debug(`implicitDescendants '${result.implicitDescendants}'`)
25+
}
26+
27+
if (typeof copy.matchDirectories === 'boolean') {
28+
result.matchDirectories = copy.matchDirectories
29+
core.debug(`matchDirectories '${result.matchDirectories}'`)
30+
}
31+
32+
if (typeof copy.omitBrokenSymbolicLinks === 'boolean') {
33+
result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks
34+
core.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`)
35+
}
36+
37+
if (typeof copy.excludeHiddenFiles === 'boolean') {
38+
result.excludeHiddenFiles = copy.excludeHiddenFiles
39+
core.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`)
40+
}
41+
}
42+
43+
return result
44+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Options to control globbing behavior
3+
*/
4+
export interface GlobOptions {
5+
/**
6+
* Indicates whether to follow symbolic links. Generally should set to false
7+
* when deleting files.
8+
*
9+
* @default true
10+
*/
11+
followSymbolicLinks?: boolean
12+
13+
/**
14+
* Indicates whether directories that match a glob pattern, should implicitly
15+
* cause all descendant paths to be matched.
16+
*
17+
* For example, given the directory `my-dir`, the following glob patterns
18+
* would produce the same results: `my-dir/**`, `my-dir/`, `my-dir`
19+
*
20+
* @default true
21+
*/
22+
implicitDescendants?: boolean
23+
24+
/**
25+
* Indicates whether matching directories should be included in the
26+
* result set.
27+
*
28+
* @default true
29+
*/
30+
matchDirectories?: boolean
31+
32+
/**
33+
* Indicates whether broken symbolic should be ignored and omitted from the
34+
* result set. Otherwise an error will be thrown.
35+
*
36+
* @default true
37+
*/
38+
omitBrokenSymbolicLinks?: boolean
39+
40+
/**
41+
* Indicates whether to exclude hidden files (files and directories starting with a `.`).
42+
* This does not apply to Windows files and directories with the hidden attribute unless
43+
* they are also prefixed with a `.`.
44+
*
45+
* @default false
46+
*/
47+
excludeHiddenFiles?: boolean
48+
}

0 commit comments

Comments
 (0)