From c7d2d2ed2ba6db6e235b193ec5023338a194cd09 Mon Sep 17 00:00:00 2001 From: Stefan Ruvceski Date: Tue, 12 Apr 2022 15:41:49 +0200 Subject: [PATCH 1/4] Added verbose mode in hashFiles --- packages/glob/src/glob.ts | 5 +++-- packages/glob/src/internal-hash-files.ts | 13 +++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/glob/src/glob.ts b/packages/glob/src/glob.ts index e1098885da..bb0ecc7191 100644 --- a/packages/glob/src/glob.ts +++ b/packages/glob/src/glob.ts @@ -26,12 +26,13 @@ export async function create( */ export async function hashFiles( patterns: string, - options?: HashFileOptions + options?: HashFileOptions, + verboseMode: Boolean = false ): Promise { let followSymbolicLinks = true if (options && typeof options.followSymbolicLinks === 'boolean') { followSymbolicLinks = options.followSymbolicLinks } const globber = await create(patterns, {followSymbolicLinks}) - return _hashFiles(globber) + return _hashFiles(globber, verboseMode) } diff --git a/packages/glob/src/internal-hash-files.ts b/packages/glob/src/internal-hash-files.ts index 8ca8ba68e2..8bd458a4c5 100644 --- a/packages/glob/src/internal-hash-files.ts +++ b/packages/glob/src/internal-hash-files.ts @@ -6,19 +6,20 @@ import * as util from 'util' import * as path from 'path' import {Globber} from './glob' -export async function hashFiles(globber: Globber): Promise { +export async function hashFiles(globber: Globber, verboseMode: Boolean = false): Promise { + const writeDelegate = verboseMode ? core.info : core.debug let hasMatch = false const githubWorkspace = process.env['GITHUB_WORKSPACE'] ?? process.cwd() const result = crypto.createHash('sha256') let count = 0 for await (const file of globber.globGenerator()) { - core.debug(file) + writeDelegate(file) if (!file.startsWith(`${githubWorkspace}${path.sep}`)) { - core.debug(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`) + writeDelegate(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`) continue } if (fs.statSync(file).isDirectory()) { - core.debug(`Skip directory '${file}'.`) + writeDelegate(`Skip directory '${file}'.`) continue } const hash = crypto.createHash('sha256') @@ -33,10 +34,10 @@ export async function hashFiles(globber: Globber): Promise { result.end() if (hasMatch) { - core.debug(`Found ${count} files to hash.`) + writeDelegate(`Found ${count} files to hash.`) return result.digest('hex') } else { - core.debug(`No matches found for glob`) + writeDelegate(`No matches found for glob`) return '' } } From 6aa7bfb9d798decbf4805be882d07cb107d3ef42 Mon Sep 17 00:00:00 2001 From: Stefan Ruvceski Date: Tue, 12 Apr 2022 19:45:59 +0200 Subject: [PATCH 2/4] Code formatting --- packages/glob/src/internal-hash-files.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/glob/src/internal-hash-files.ts b/packages/glob/src/internal-hash-files.ts index 8bd458a4c5..53f4b960a6 100644 --- a/packages/glob/src/internal-hash-files.ts +++ b/packages/glob/src/internal-hash-files.ts @@ -6,7 +6,10 @@ import * as util from 'util' import * as path from 'path' import {Globber} from './glob' -export async function hashFiles(globber: Globber, verboseMode: Boolean = false): Promise { +export async function hashFiles( + globber: Globber, + verboseMode: Boolean = false +): Promise { const writeDelegate = verboseMode ? core.info : core.debug let hasMatch = false const githubWorkspace = process.env['GITHUB_WORKSPACE'] ?? process.cwd() From 46760bd6d65e7fdb2967cf4702a49d4185e1ddf5 Mon Sep 17 00:00:00 2001 From: ruvceskistefan <96768603+ruvceskistefan@users.noreply.github.com> Date: Tue, 12 Apr 2022 23:00:10 +0200 Subject: [PATCH 3/4] Change verboseMode arg to verbose Co-authored-by: Thomas Boop <52323235+thboop@users.noreply.github.com> --- packages/glob/src/glob.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/glob/src/glob.ts b/packages/glob/src/glob.ts index bb0ecc7191..1f0228ce7c 100644 --- a/packages/glob/src/glob.ts +++ b/packages/glob/src/glob.ts @@ -27,7 +27,7 @@ export async function create( export async function hashFiles( patterns: string, options?: HashFileOptions, - verboseMode: Boolean = false + verbose: Boolean = false ): Promise { let followSymbolicLinks = true if (options && typeof options.followSymbolicLinks === 'boolean') { From 6f7ef6ee1d6ec6e8527135df702e19d276f88202 Mon Sep 17 00:00:00 2001 From: Stefan Ruvceski Date: Wed, 13 Apr 2022 10:33:16 +0200 Subject: [PATCH 4/4] Using verbose instead of verboseMode as arg --- packages/glob/src/glob.ts | 2 +- packages/glob/src/internal-hash-files.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/glob/src/glob.ts b/packages/glob/src/glob.ts index 1f0228ce7c..acbb6d2cf3 100644 --- a/packages/glob/src/glob.ts +++ b/packages/glob/src/glob.ts @@ -34,5 +34,5 @@ export async function hashFiles( followSymbolicLinks = options.followSymbolicLinks } const globber = await create(patterns, {followSymbolicLinks}) - return _hashFiles(globber, verboseMode) + return _hashFiles(globber, verbose) } diff --git a/packages/glob/src/internal-hash-files.ts b/packages/glob/src/internal-hash-files.ts index 53f4b960a6..ef18d9f581 100644 --- a/packages/glob/src/internal-hash-files.ts +++ b/packages/glob/src/internal-hash-files.ts @@ -8,9 +8,9 @@ import {Globber} from './glob' export async function hashFiles( globber: Globber, - verboseMode: Boolean = false + verbose: Boolean = false ): Promise { - const writeDelegate = verboseMode ? core.info : core.debug + const writeDelegate = verbose ? core.info : core.debug let hasMatch = false const githubWorkspace = process.env['GITHUB_WORKSPACE'] ?? process.cwd() const result = crypto.createHash('sha256')