Unverified Commit afc7e4a2 authored by Ryan Troost's avatar Ryan Troost Committed by GitHub
Browse files

Exclude hidden files by default backport

parent a8a3f3ad
Loading
Loading
Loading
Loading
+51
Changes for __tests__/search.test.ts: 51 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -61,6 +61,20 @@ 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 fileInHiddenFolderInFolderA = path.join(
  root,
  'folder-a',
  '.hidden-folder-in-folder-a',
  'file.txt'
)

describe('Search', () => {
  beforeAll(async () => {
    // mock all output so that there is less noise when running tests
@@ -92,6 +106,13 @@ describe('Search', () => {
    await fs.mkdir(path.join(root, 'folder-h', 'folder-j', 'folder-k'), {
      recursive: true
    })
    await fs.mkdir(
      path.join(root, '.hidden-folder', 'folder-in-hidden-folder'),
      {recursive: true}
    )
    await fs.mkdir(path.join(root, 'folder-a', '.hidden-folder-in-folder-a'), {
      recursive: true
    })

    await fs.writeFile(searchItem1Path, 'search item1 file')
    await fs.writeFile(searchItem2Path, 'search item2 file')
@@ -110,10 +131,19 @@ 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/
          .hidden-folder/
            folder-in-hidden-folder/
              file.txt
          folder-a/
              .hidden-folder-in-folder-a/
                file.txt
              folder-b/
                  folder-c/
                      search-item1.txt
@@ -136,6 +166,7 @@ describe('Search', () => {
              folder-j/
                  folder-k/
                      lonely-file.txt
          .hidden-file.txt
          search-item5.txt
    */
  })
@@ -352,4 +383,24 @@ describe('Search', () => {
    )
    expect(searchResult.filesToUpload.includes(lonelyFilePath)).toEqual(true)
  })

  it('Hidden files ignored by default', async () => {
    const searchPath = path.join(root, '**/*')
    const searchResult = await findFilesToUpload(searchPath)

    expect(searchResult.filesToUpload).not.toContain(hiddenFile)
    expect(searchResult.filesToUpload).not.toContain(fileInHiddenFolderPath)
    expect(searchResult.filesToUpload).not.toContain(
      fileInHiddenFolderInFolderA
    )
  })

  it('Hidden files included', async () => {
    const searchPath = path.join(root, '**/*')
    const searchResult = await findFilesToUpload(searchPath, true)

    expect(searchResult.filesToUpload).toContain(hiddenFile)
    expect(searchResult.filesToUpload).toContain(fileInHiddenFolderPath)
    expect(searchResult.filesToUpload).toContain(fileInHiddenFolderInFolderA)
  })
})
+102 −53

File changed.

Preview size limit exceeded, changes collapsed.

+9 −9

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Changes for package.json: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@
  "dependencies": {
    "@actions/artifact": "^1.1.2",
    "@actions/core": "^1.10.0",
    "@actions/glob": "^0.3.0",
    "@actions/glob": "^0.5.0",
    "@actions/io": "^1.1.2"
  },
  "devDependencies": {
+2 −1

File changed.

Preview size limit exceeded, changes collapsed.

Loading