Skip to content

Commit

Permalink
fix: chunkFiles chunks normalized files even when maxArgLength is set (
Browse files Browse the repository at this point in the history
…#858)

The previous commit only fixed the situation when maxArgLength was not set (when used through the Node.js API).
  • Loading branch information
iiroj authored May 1, 2020
1 parent 5883296 commit fc72170
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/chunkFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ module.exports = function chunkFiles({ files, baseDir, maxArgLength = null, rela
)
const chunkCount = Math.min(Math.ceil(fileListLength / maxArgLength), normalizedFiles.length)
debug(`Creating ${chunkCount} chunks for maxArgLength of ${maxArgLength}`)
return chunkArray(files, chunkCount)
return chunkArray(normalizedFiles, chunkCount)
}
15 changes: 10 additions & 5 deletions test/chunkFiles.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ describe('chunkFiles', () => {
})

it('should not chunk short argument string', () => {
const chunkedFiles = chunkFiles({ baseDir, files, maxArgLength: 1000 })
const chunkedFiles = chunkFiles({ baseDir, files, maxArgLength: 1000, relative: true })
expect(chunkedFiles).toEqual([files])
})

it('should chunk too long argument string', () => {
const chunkedFiles = chunkFiles({ baseDir, files, maxArgLength: 20 })
expect(chunkedFiles).toEqual(files.map((file) => [file]))
const chunkedFiles = chunkFiles({ baseDir, files, maxArgLength: 20, relative: false })
expect(chunkedFiles).toEqual(files.map((file) => [normalize(path.resolve(baseDir, file))]))
})

it('should take into account relative setting', () => {
Expand All @@ -30,8 +30,13 @@ describe('chunkFiles', () => {
])
})

it('should resolve paths when relative: false', () => {
const chunkedFiles = chunkFiles({ baseDir, files, relative: false })
it('should resolve absolute paths by default', () => {
const chunkedFiles = chunkFiles({ baseDir, files })
expect(chunkedFiles).toEqual([files.map((file) => normalize(path.resolve(baseDir, file)))])
})

it('should resolve absolute paths by default even when maxArgLength is set', () => {
const chunkedFiles = chunkFiles({ baseDir, files, maxArgLength: 262144 })
expect(chunkedFiles).toEqual([files.map((file) => normalize(path.resolve(baseDir, file)))])
})
})

0 comments on commit fc72170

Please sign in to comment.