From a0c40cf60283f329afac2bc0fa77f1a59fa11e6e Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Thu, 15 Aug 2024 17:26:43 -0400 Subject: [PATCH] Update to latest `@actions/glob` and fix tests --- __tests__/search.test.ts | 26 ++++++++++++-------------- package-lock.json | 18 +++++++++--------- package.json | 2 +- src/shared/search.ts | 4 ++-- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/__tests__/search.test.ts b/__tests__/search.test.ts index 5cbc032..58f41ab 100644 --- a/__tests__/search.test.ts +++ b/__tests__/search.test.ts @@ -61,13 +61,13 @@ const lonelyFilePath = path.join( 'lonely-file.txt' ) +const hiddenFile = path.join(root, '.hidden-file.txt') const fileInHiddenFolderPath = path.join( root, '.hidden-folder', 'folder-in-hidden-folder', 'file.txt' ) -const hiddenFile = path.join(root, '.hidden-file.txt') const fileInHiddenFolderInFolderA = path.join( root, 'folder-a', @@ -132,6 +132,10 @@ describe('Search', () => { await fs.writeFile(amazingFileInFolderHPath, 'amazing file') await fs.writeFile(lonelyFilePath, 'all by itself') + + await fs.writeFile(hiddenFile, 'hidden file') + await fs.writeFile(fileInHiddenFolderPath, 'file in hidden directory') + await fs.writeFile(fileInHiddenFolderInFolderA, 'file in hidden directory') /* Directory structure of files that get created: root/ @@ -385,25 +389,19 @@ describe('Search', () => { const searchPath = path.join(root, '**/*') const searchResult = await findFilesToUpload(searchPath) - expect(searchResult.filesToUpload.includes(hiddenFile)).toEqual(false) - expect(searchResult.filesToUpload.includes(fileInHiddenFolderPath)).toEqual( - false + expect(searchResult.filesToUpload).not.toContain(hiddenFile) + expect(searchResult.filesToUpload).not.toContain(fileInHiddenFolderPath) + expect(searchResult.filesToUpload).not.toContain( + fileInHiddenFolderInFolderA ) - expect( - searchResult.filesToUpload.includes(fileInHiddenFolderInFolderA) - ).toEqual(false) }) it('Hidden files included', async () => { const searchPath = path.join(root, '**/*') const searchResult = await findFilesToUpload(searchPath, true) - expect(searchResult.filesToUpload.includes(hiddenFile)).toEqual(false) - expect(searchResult.filesToUpload.includes(fileInHiddenFolderPath)).toEqual( - false - ) - expect( - searchResult.filesToUpload.includes(fileInHiddenFolderInFolderA) - ).toEqual(false) + expect(searchResult.filesToUpload).toContain(hiddenFile) + expect(searchResult.filesToUpload).toContain(fileInHiddenFolderPath) + expect(searchResult.filesToUpload).toContain(fileInHiddenFolderInFolderA) }) }) diff --git a/package-lock.json b/package-lock.json index e1c4ca9..6c1729e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@actions/artifact": "2.1.8", "@actions/core": "^1.10.1", "@actions/github": "^6.0.0", - "@actions/glob": "^0.3.0", + "@actions/glob": "^0.5.0", "@actions/io": "^1.1.2", "minimatch": "^9.0.3" }, @@ -191,11 +191,11 @@ } }, "node_modules/@actions/glob": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.3.0.tgz", - "integrity": "sha512-tJP1ZhF87fd6LBnaXWlahkyvdgvsLl7WnreW1EZaC8JWjpMXmzqWzQVe/IEYslrkT9ymibVrKyJN4UMD7uQM2w==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.5.0.tgz", + "integrity": "sha512-tST2rjPvJLRZLuT9NMUtyBjvj9Yo0MiJS3ow004slMvm8GFM+Zv9HvMJ7HWzfUyJnGrJvDsYkWBaaG3YKXRtCw==", "dependencies": { - "@actions/core": "^1.2.6", + "@actions/core": "^1.9.1", "minimatch": "^3.0.4" } }, @@ -8036,11 +8036,11 @@ } }, "@actions/glob": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.3.0.tgz", - "integrity": "sha512-tJP1ZhF87fd6LBnaXWlahkyvdgvsLl7WnreW1EZaC8JWjpMXmzqWzQVe/IEYslrkT9ymibVrKyJN4UMD7uQM2w==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.5.0.tgz", + "integrity": "sha512-tST2rjPvJLRZLuT9NMUtyBjvj9Yo0MiJS3ow004slMvm8GFM+Zv9HvMJ7HWzfUyJnGrJvDsYkWBaaG3YKXRtCw==", "requires": { - "@actions/core": "^1.2.6", + "@actions/core": "^1.9.1", "minimatch": "^3.0.4" }, "dependencies": { diff --git a/package.json b/package.json index 7219abe..f43f656 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@actions/artifact": "2.1.8", "@actions/core": "^1.10.1", "@actions/github": "^6.0.0", - "@actions/glob": "^0.3.0", + "@actions/glob": "^0.5.0", "@actions/io": "^1.1.2", "minimatch": "^9.0.3" }, diff --git a/src/shared/search.ts b/src/shared/search.ts index c468f14..67b2422 100644 --- a/src/shared/search.ts +++ b/src/shared/search.ts @@ -11,12 +11,12 @@ export interface SearchResult { rootDirectory: string } -function getDefaultGlobOptions(_includeHiddenFiles: boolean): glob.GlobOptions { +function getDefaultGlobOptions(includeHiddenFiles: boolean): glob.GlobOptions { return { followSymbolicLinks: true, implicitDescendants: true, omitBrokenSymbolicLinks: true, - // excludeHiddenFiles: !includeHiddenFiles, + excludeHiddenFiles: !includeHiddenFiles, } }