From 41b0f533b7c47b2fa08a3764742d64fcfa08d97a Mon Sep 17 00:00:00 2001 From: Ricardo Gobbo de Souza Date: Mon, 7 Oct 2019 19:02:34 -0300 Subject: [PATCH] fix: convert back-slashes (#186) --- src/LintDirtyModulesPlugin.js | 2 +- test/lint-dirty-modules-only.test.js | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/LintDirtyModulesPlugin.js b/src/LintDirtyModulesPlugin.js index 6952d74..6832e92 100644 --- a/src/LintDirtyModulesPlugin.js +++ b/src/LintDirtyModulesPlugin.js @@ -20,7 +20,7 @@ export default class LintDirtyModulesPlugin { } const dirtyOptions = { ...this.options }; - const glob = dirtyOptions.files.join('|'); + const glob = dirtyOptions.files.join('|').replace(/\\/g, '/'); const changedFiles = this.getChangedFiles(compilation.fileTimestamps, glob); this.prevTimestamps = compilation.fileTimestamps; diff --git a/test/lint-dirty-modules-only.test.js b/test/lint-dirty-modules-only.test.js index da54570..122e34d 100644 --- a/test/lint-dirty-modules-only.test.js +++ b/test/lint-dirty-modules-only.test.js @@ -12,7 +12,7 @@ describe('lint dirty modules only', () => { beforeAll(() => { callback = jest.fn(); - plugin = new LintDirtyModulesPlugin(null, { files: ['**/*.s?(c|a)ss'] }); + plugin = new LintDirtyModulesPlugin(null, { files: ['**\\*.s?(c|a)ss'] }); plugin.isFirstRun = false; }); @@ -32,9 +32,16 @@ describe('lint dirty modules only', () => { }); it('linting on change file', () => { - const fileTimestamps = new Map([['changed.scss', 1], ['new-file.scss']]); - - plugin.prevTimestamps = new Map([['changed.scss', 2]]); + const fileTimestamps = new Map([ + ['foo/changed.scss', 1], + ['bar\\changed.scss', 1], + ['new-file.scss'], + ]); + + plugin.prevTimestamps = new Map([ + ['foo/changed.scss', 2], + ['bar\\changed.scss', 2], + ]); plugin.apply({ fileTimestamps }, callback); expect(linter).toBeCalledTimes(1);