From 300e0a3e66eb42915aaea6e15046d03c3dfc202a Mon Sep 17 00:00:00 2001 From: Matthew Wagerfield Date: Sat, 16 Feb 2019 15:36:20 +0000 Subject: [PATCH 1/4] fix: readJSFiles for strings --- packages/workbox/lib/utils.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/workbox/lib/utils.js b/packages/workbox/lib/utils.js index 1ff442c7..79e79e9c 100644 --- a/packages/workbox/lib/utils.js +++ b/packages/workbox/lib/utils.js @@ -1,7 +1,11 @@ const { readFileSync, existsSync } = require('fs') +function isString (value) { + return typeof value === "string" +} + function readJSFiles (files) { - return Array.from(files) + return Array.from(isString(files) ? [files] : files) .map(path => { path = this.nuxt.resolver.resolvePath(path) if (path && existsSync(path)) { From 9bc88aee4c8373a8634f597b119db5ca9589263e Mon Sep 17 00:00:00 2001 From: Matthew Wagerfield Date: Sat, 16 Feb 2019 15:38:48 +0000 Subject: [PATCH 2/4] fix: updated extensions docs --- docs/modules/workbox.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/modules/workbox.md b/docs/modules/workbox.md index d0ee281e..62fc541c 100644 --- a/docs/modules/workbox.md +++ b/docs/modules/workbox.md @@ -67,7 +67,7 @@ It is recommanded to test workbox using `nuxt build`/`nuxt start`. You can enabl ### `workboxExtensions` -(String) Loads and inserts the contents of the specified file path into the service worker script before any call to `precacheAndRoute`. You may add as many extra calls as you want to this file. +(String|String[]) Loads and inserts the contents of the specified file path into the service worker script before any call to `precacheAndRoute`. You may add as many extra calls as you want to these files. @@ -91,7 +91,7 @@ Workbox takes a lot of the heavy lifting out of precaching by simplifying the AP ### `cachingExtensions` -(String) Loads and inserts the contents of the specified file path into the service worker script, below autogenerated calls to `workbox.precaching.*`. You may add as many extra calls as you want to this file. +(String|String[]) Loads and inserts the contents of the specified file path into the service worker script, below autogenerated calls to `workbox.precaching.*`. You may add as many extra calls as you want to these files. ### `cleanupOutdatedCaches` @@ -129,7 +129,7 @@ Workbox takes a lot of the heavy lifting out of precaching by simplifying the AP ### `routingExtensions` -(String) Loads and inserts the contents of the specified file path into the service worker script, below autogenerated calls to `workbox.routing.*`. You may add as many extra calls as you want to this file. +(String|String[]) Loads and inserts the contents of the specified file path into the service worker script, below autogenerated calls to `workbox.routing.*`. You may add as many extra calls as you want to these files. ### `assetsURLPattern` From 489816ba9c96fa0f6a95fbbab3f4059e9b3626f0 Mon Sep 17 00:00:00 2001 From: Matthew Wagerfield Date: Sat, 16 Feb 2019 15:52:54 +0000 Subject: [PATCH 3/4] style: replaced double quotes with single quotes --- packages/workbox/lib/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/workbox/lib/utils.js b/packages/workbox/lib/utils.js index 79e79e9c..85f711b9 100644 --- a/packages/workbox/lib/utils.js +++ b/packages/workbox/lib/utils.js @@ -1,7 +1,7 @@ const { readFileSync, existsSync } = require('fs') function isString (value) { - return typeof value === "string" + return typeof value === 'string' } function readJSFiles (files) { From b7a21f8c65c369d0d25a5bdc5b240d47d5201ff5 Mon Sep 17 00:00:00 2001 From: Matthew Wagerfield Date: Sat, 16 Feb 2019 17:16:51 +0000 Subject: [PATCH 4/4] refactor: replaced isString with isArray --- packages/workbox/lib/utils.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/workbox/lib/utils.js b/packages/workbox/lib/utils.js index 85f711b9..bc991f54 100644 --- a/packages/workbox/lib/utils.js +++ b/packages/workbox/lib/utils.js @@ -1,11 +1,7 @@ const { readFileSync, existsSync } = require('fs') -function isString (value) { - return typeof value === 'string' -} - function readJSFiles (files) { - return Array.from(isString(files) ? [files] : files) + return Array.from(Array.isArray(files) ? files : [files]) .map(path => { path = this.nuxt.resolver.resolvePath(path) if (path && existsSync(path)) {