Skip to content

Commit

Permalink
feat(config): Provide a default empty object for preprocessor_priority
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjbarton committed May 1, 2019
1 parent 60579fd commit 7c65eb8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
1 change: 1 addition & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ class Config {
this.proxies = {}
this.proxyValidateSSL = true
this.preprocessors = {}
this.preprocessor_priority = {}
this.urlRoot = '/'
this.upstreamProxy = undefined
this.reportSlowerThan = 0
Expand Down
1 change: 0 additions & 1 deletion lib/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down
30 changes: 15 additions & 15 deletions test/unit/preprocessor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'}

Expand All @@ -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'}

Expand All @@ -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'}

Expand All @@ -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'}

Expand All @@ -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'}

Expand All @@ -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, () => {
Expand Down Expand Up @@ -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'}
Expand All @@ -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'}

Expand All @@ -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'}

Expand Down Expand Up @@ -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
Expand All @@ -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, () => { })

Expand All @@ -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'}

Expand All @@ -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'}

Expand All @@ -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'}

Expand Down Expand Up @@ -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'}

Expand Down

0 comments on commit 7c65eb8

Please sign in to comment.