Skip to content

Commit

Permalink
fix: file-hash now accepts legacy configuration format
Browse files Browse the repository at this point in the history
  • Loading branch information
prototypicalpro committed Nov 19, 2020
1 parent ae6688c commit d509274
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rules/file-hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const FileSystem = require('../lib/file_system')
*/
async function fileHash (fs, options) {
const fileList = options.globsAny || options.files
const file = await fs.findFirstFile(options.globsAny, options.nocase)
const file = await fs.findFirstFile(fileList, options.nocase)

if (file === undefined) {
return new Result(
Expand Down
23 changes: 23 additions & 0 deletions tests/rules/file_hash_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,28 @@ describe('rule', () => {

expect(actual.passed).to.equal(true)
})

it('respect the legacy configuration format', async () => {
/** @type {any} */
const mockfs = {
findFirstFile () {
return 'README.md'
},
getFileContents () {
return 'foo'
},
targetDir: '.'
}

const ruleopts = {
files: ['README.md'],
hash: '2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae'
}

const actual = await fileContents(mockfs, ruleopts)
expect(actual.passed).to.equal(true)
expect(actual.targets).to.have.length(1)
expect(actual.targets[0]).to.deep.include({ passed: true, path: 'README.md' })
})
})
})

0 comments on commit d509274

Please sign in to comment.