Skip to content

Commit

Permalink
Update to latest @actions/glob and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmgross committed Aug 15, 2024
1 parent acb59e4 commit a0c40cf
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 26 deletions.
26 changes: 12 additions & 14 deletions __tests__/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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/
Expand Down Expand Up @@ -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)
})
})
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
4 changes: 2 additions & 2 deletions src/shared/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Check failure on line 19 in src/shared/search.ts

View workflow job for this annotation

GitHub Actions / Build (windows-latest)

Delete `,`
}
}

Expand Down

0 comments on commit a0c40cf

Please sign in to comment.