Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix readJSFiles #143

Merged
merged 6 commits into from
Feb 16, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/modules/workbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<!-- Precache -->

Expand All @@ -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`

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

Expand Down
6 changes: 5 additions & 1 deletion packages/workbox/lib/utils.js
Original file line number Diff line number Diff line change
@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest using Array.isArray here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

.map(path => {
path = this.nuxt.resolver.resolvePath(path)
if (path && existsSync(path)) {
Expand Down