Skip to content

Commit 8f2bd5d

Browse files
Added verbose mode in hashFiles (#1052)
* Added verbose mode in hashFiles * Code formatting * Change verboseMode arg to verbose Co-authored-by: Thomas Boop <52323235+thboop@users.noreply.github.com> * Using verbose instead of verboseMode as arg Co-authored-by: Thomas Boop <52323235+thboop@users.noreply.github.com>
1 parent 7654d97 commit 8f2bd5d

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

‎packages/glob/src/glob.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ export async function create(
2626
*/
2727
export async function hashFiles(
2828
patterns: string,
29-
options?: HashFileOptions
29+
options?: HashFileOptions,
30+
verbose: Boolean = false
3031
): Promise<string> {
3132
let followSymbolicLinks = true
3233
if (options && typeof options.followSymbolicLinks === 'boolean') {
3334
followSymbolicLinks = options.followSymbolicLinks
3435
}
3536
const globber = await create(patterns, {followSymbolicLinks})
36-
return _hashFiles(globber)
37+
return _hashFiles(globber, verbose)
3738
}

‎packages/glob/src/internal-hash-files.ts‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,23 @@ import * as util from 'util'
66
import * as path from 'path'
77
import {Globber} from './glob'
88

9-
export async function hashFiles(globber: Globber): Promise<string> {
9+
export async function hashFiles(
10+
globber: Globber,
11+
verbose: Boolean = false
12+
): Promise<string> {
13+
const writeDelegate = verbose ? core.info : core.debug
1014
let hasMatch = false
1115
const githubWorkspace = process.env['GITHUB_WORKSPACE'] ?? process.cwd()
1216
const result = crypto.createHash('sha256')
1317
let count = 0
1418
for await (const file of globber.globGenerator()) {
15-
core.debug(file)
19+
writeDelegate(file)
1620
if (!file.startsWith(`${githubWorkspace}${path.sep}`)) {
17-
core.debug(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`)
21+
writeDelegate(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`)
1822
continue
1923
}
2024
if (fs.statSync(file).isDirectory()) {
21-
core.debug(`Skip directory '${file}'.`)
25+
writeDelegate(`Skip directory '${file}'.`)
2226
continue
2327
}
2428
const hash = crypto.createHash('sha256')
@@ -33,10 +37,10 @@ export async function hashFiles(globber: Globber): Promise<string> {
3337
result.end()
3438

3539
if (hasMatch) {
36-
core.debug(`Found ${count} files to hash.`)
40+
writeDelegate(`Found ${count} files to hash.`)
3741
return result.digest('hex')
3842
} else {
39-
core.debug(`No matches found for glob`)
43+
writeDelegate(`No matches found for glob`)
4044
return ''
4145
}
4246
}

0 commit comments

Comments
 (0)