Skip to content

Commit

Permalink
feat(workbox, onegisnal): Use defaultsDeep for options
Browse files Browse the repository at this point in the history
  • Loading branch information
Pooya Parsa committed Nov 17, 2017
1 parent d67df15 commit 5ac89cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/onesignal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const path = require('path')
const { writeFileSync, readFileSync } = require('fs')
const hashSum = require('hash-sum')
const debug = require('debug')('nuxt:pwa')
const { defaultsDeep } = require('lodash')

const fixUrl = url => url.replace(/\/\//g, '/').replace(':/', '://')
const isUrl = url => url.indexOf('http') === 0 || url.indexOf('//') === 0
Expand Down Expand Up @@ -55,7 +56,7 @@ function addOneSignal (moduleOptions) {
}
}

const options = Object.assign(defaults, moduleOptions, this.options.oneSignal)
const options = defaultsDeep({}, this.options.oneSignal, moduleOptions, defaults)

if (options.OneSignalSDK === undefined) {
if (options.cdn) {
Expand Down
7 changes: 5 additions & 2 deletions packages/workbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { readFileSync, writeFileSync } = require('fs')
const hashSum = require('hash-sum')
const escapeStringRegexp = require('escape-string-regexp')
const debug = require('debug')('nuxt:pwa')
const { defaultsDeep } = require('lodash')

const fixUrl = url => url.replace(/\/\//g, '/').replace(':/', '://')
const isUrl = url => url.indexOf('http') === 0 || url.indexOf('//') === 0
Expand Down Expand Up @@ -43,7 +44,7 @@ function getOptions (moduleOptions) {
}
}

const options = Object.assign({
const defaults = {
autoRegister: true,
routerBase,
publicPath,
Expand All @@ -70,7 +71,9 @@ function getOptions (moduleOptions) {
handler: 'networkFirst'
}
]
}, moduleOptions, this.options.workbox)
}

const options = defaultsDeep({}, this.options.workbox, moduleOptions, defaults)

return options
}
Expand Down

0 comments on commit 5ac89cf

Please sign in to comment.