From 7c65eb86c2ae520c3cb35e5417460d34d05deec3 Mon Sep 17 00:00:00 2001 From: johnjbarton Date: Wed, 1 May 2019 07:42:50 -0700 Subject: [PATCH] feat(config): Provide a default empty object for preprocessor_priority --- lib/config.js | 1 + lib/preprocessor.js | 1 - test/unit/preprocessor.spec.js | 30 +++++++++++++++--------------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/config.js b/lib/config.js index 67f05d1b8..cad4d7d9b 100644 --- a/lib/config.js +++ b/lib/config.js @@ -302,6 +302,7 @@ class Config { this.proxies = {} this.proxyValidateSSL = true this.preprocessors = {} + this.preprocessor_priority = {} this.urlRoot = '/' this.upstreamProxy = undefined this.reportSlowerThan = 0 diff --git a/lib/preprocessor.js b/lib/preprocessor.js index a7dcbabb6..ff4379c26 100644 --- a/lib/preprocessor.js +++ b/lib/preprocessor.js @@ -38,7 +38,6 @@ function createPreprocessor (config, preprocessorPriority, basePath, injector) { const alreadyDisplayedErrors = {} const instances = {} let patterns = Object.keys(config) - preprocessorPriority = preprocessorPriority || {} function instantiatePreprocessor (name) { if (alreadyDisplayedErrors[name]) { diff --git a/test/unit/preprocessor.spec.js b/test/unit/preprocessor.spec.js index 6caf71194..13c3644ee 100644 --- a/test/unit/preprocessor.spec.js +++ b/test/unit/preprocessor.spec.js @@ -47,7 +47,7 @@ describe('preprocessor', () => { 'factory', function () { return fakePreprocessor } ] }, emitterSetting]) - pp = m.createPreprocessor({'**/*.js': ['fake']}, undefined, null, injector) + pp = m.createPreprocessor({'**/*.js': ['fake']}, {}, null, injector) const file = {originalPath: '/some/a.js', path: 'path'} @@ -68,7 +68,7 @@ describe('preprocessor', () => { const injector = new di.Injector([{ 'preprocessor:fake': ['factory', function () { return fakePreprocessor }] }, emitterSetting]) - pp = m.createPreprocessor({'**/*.js': ['fake']}, undefined, null, injector) + pp = m.createPreprocessor({'**/*.js': ['fake']}, {}, null, injector) const file = {originalPath: '/some/.dir/a.js', path: 'path'} @@ -90,7 +90,7 @@ describe('preprocessor', () => { 'preprocessor:fake': ['factory', function () { return fakePreprocessor }] }, emitterSetting]) const config = {'**/*.txt': ['fake']} - pp = m.createPreprocessor(config, undefined, null, injector) + pp = m.createPreprocessor(config, {}, null, injector) const file = {originalPath: '/some/a.js', path: 'path'} @@ -112,7 +112,7 @@ describe('preprocessor', () => { const injector = new di.Injector([{ 'preprocessor:fake': ['factory', function () { return fakePreprocessor }] }, emitterSetting]) - pp = m.createPreprocessor({'**/*.js': ['fake']}, undefined, null, injector) + pp = m.createPreprocessor({'**/*.js': ['fake']}, {}, null, injector) const file = {originalPath: '/some/a.txt', path: 'path'} @@ -138,7 +138,7 @@ describe('preprocessor', () => { 'preprocessor:fake2': ['factory', function () { return fakePreprocessor2 }] }, emitterSetting]) - pp = m.createPreprocessor({'**/*.js': ['fake1', 'fake2']}, undefined, null, injector) + pp = m.createPreprocessor({'**/*.js': ['fake1', 'fake2']}, {}, null, injector) const file = {originalPath: '/some/a.js', path: 'path'} @@ -152,7 +152,7 @@ describe('preprocessor', () => { }) it('should compute SHA', (done) => { - pp = m.createPreprocessor({}, undefined, null, new di.Injector([emitterSetting])) + pp = m.createPreprocessor({}, {}, null, new di.Injector([emitterSetting])) const file = {originalPath: '/some/a.js', path: 'path'} pp(file, () => { @@ -182,7 +182,7 @@ describe('preprocessor', () => { 'preprocessor:fake': ['factory', function () { return fakePreprocessor }] }, emitterSetting]) - pp = m.createPreprocessor({'**/a.js': ['fake']}, undefined, null, injector) + pp = m.createPreprocessor({'**/a.js': ['fake']}, {}, null, injector) const fileProcess = {originalPath: '/some/a.js', path: 'path'} const fileSkip = {originalPath: '/some/b.js', path: 'path'} @@ -208,7 +208,7 @@ describe('preprocessor', () => { 'preprocessor:failing': ['factory', function () { return failingPreprocessor }] }, emitterSetting]) - pp = m.createPreprocessor({'**/*.js': ['failing']}, undefined, null, injector) + pp = m.createPreprocessor({'**/*.js': ['failing']}, {}, null, injector) const file = {originalPath: '/some/a.js', path: 'path'} @@ -232,7 +232,7 @@ describe('preprocessor', () => { 'preprocessor:fake': ['factory', function () { return fakePreprocessor }] }, emitterSetting]) - pp = m.createPreprocessor({'**/*.js': ['failing', 'fake']}, undefined, null, injector) + pp = m.createPreprocessor({'**/*.js': ['failing', 'fake']}, {}, null, injector) const file = {originalPath: '/some/a.js', path: 'path'} @@ -261,7 +261,7 @@ describe('preprocessor', () => { 'preprocessor:fake': ['factory', function () { return fakePreprocessor }] }, emitterSetting]) - const pp = m.createPreprocessor({'**/*.js': ['fake']}, undefined, null, injector) + const pp = m.createPreprocessor({'**/*.js': ['fake']}, {}, null, injector) pp(file, () => { expect(fakePreprocessor).to.have.been.called @@ -277,7 +277,7 @@ describe('preprocessor', () => { it('should throw after 3 retries', (done) => { const injector = new di.Injector([{}, emitterSetting]) - const pp = m.createPreprocessor({'**/*.js': []}, undefined, null, injector) + const pp = m.createPreprocessor({'**/*.js': []}, {}, null, injector) pp(file, () => { }) @@ -299,7 +299,7 @@ describe('preprocessor', () => { 'preprocessor:fake': ['factory', function () { return fakePreprocessor }] }, emitterSetting]) - pp = m.createPreprocessor({'**/*': ['fake']}, undefined, null, injector) + pp = m.createPreprocessor({'**/*': ['fake']}, {}, null, injector) const file = {originalPath: '/some/photo.png', path: 'path'} @@ -322,7 +322,7 @@ describe('preprocessor', () => { 'preprocessor:fake': ['factory', function () { return fakePreprocessor }] }, emitterSetting]) - pp = m.createPreprocessor({'**/*': ['fake']}, undefined, null, injector) + pp = m.createPreprocessor({'**/*': ['fake']}, {}, null, injector) const file = {originalPath: '/some/photo.png', path: 'path'} @@ -344,7 +344,7 @@ describe('preprocessor', () => { 'preprocessor:fake': ['factory', function () { fakePreprocessor }] }, emitterSetting]) - pp = m.createPreprocessor({'**/*': ['fake']}, undefined, null, injector) + pp = m.createPreprocessor({'**/*': ['fake']}, {}, null, injector) const file = {originalPath: '/some/CAM_PHOTO.JPG', path: 'path'} @@ -387,7 +387,7 @@ describe('preprocessor', () => { '/*/a.js': ['fakeA', 'fakeB'], '/some/*': ['fakeB', 'fakeC'], '/some/a.js': ['fakeD'] - }, undefined, null, injector) + }, {}, null, injector) const file = {originalPath: '/some/a.js', path: 'path'}