From d50927423c965054d154adb56aaf1c48db778182 Mon Sep 17 00:00:00 2001 From: Noah Koontz Date: Thu, 19 Nov 2020 09:27:33 -0800 Subject: [PATCH] fix: file-hash now accepts legacy configuration format --- rules/file-hash.js | 2 +- tests/rules/file_hash_tests.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/rules/file-hash.js b/rules/file-hash.js index 79e37455..a9ff2977 100644 --- a/rules/file-hash.js +++ b/rules/file-hash.js @@ -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( diff --git a/tests/rules/file_hash_tests.js b/tests/rules/file_hash_tests.js index 2254e67a..0fc157f4 100644 --- a/tests/rules/file_hash_tests.js +++ b/tests/rules/file_hash_tests.js @@ -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' }) + }) }) })