Skip to content

Commit

Permalink
Refactored the default globPatterns to be []
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffposnick committed Dec 21, 2017
1 parent bd5091b commit 1aed68d
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 16 deletions.
4 changes: 1 addition & 3 deletions packages/workbox-build/src/entry-points/options/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
*/

module.exports = {
getManifestGlobPatterns: [],
generateSWStringGlobPatterns: [],
globFollow: true,
globIgnores: ['**/node_modules/**/*'],
globPatterns: ['**/*.{js,css,html}'],
globPatterns: [],
globStrict: true,
maximumFileSizeToCacheInBytes: 2 * 1024 * 1024,
clientsClaim: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@
const joi = require('joi');

const commonGenerateSchema = require('./common-generate-schema');
const defaults = require('./defaults');

// Define some additional constraints.
module.exports = commonGenerateSchema.keys({
globDirectory: joi.string(),
globPatterns: joi.array().items(joi.string()).default(
defaults.generateSWStringGlobPatterns),
importScripts: joi.array().items(joi.string()).required(),
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@
const joi = require('joi');

const baseSchema = require('./base-schema');
const defaults = require('./defaults');

// Define some additional constraints.
module.exports = baseSchema.keys({
globDirectory: joi.string().required(),
globPatterns: joi.array().items(joi.string()).default(
defaults.generateSWStringGlobPatterns),
});
1 change: 1 addition & 0 deletions test/workbox-build/node/entry-points/generate-sw-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe(`[workbox-build] entry-points/generate-sw-string.js (End to End)`, func
const DEFAULT_IMPORT_SCRIPTS = ['workbox.js'];
const BASE_OPTIONS = {
importScripts: DEFAULT_IMPORT_SCRIPTS,
globPatterns: ['**/*.{js,css,html}'],
};
const REQUIRED_PARAMS = [
'importScripts',
Expand Down
1 change: 1 addition & 0 deletions test/workbox-build/node/entry-points/generate-sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe(`[workbox-build] entry-points/generate-sw.js (End to End)`, function()
const GLOB_DIR = path.join(__dirname, '..', '..', 'static', 'example-project-1');
const BASE_OPTIONS = {
globDirectory: GLOB_DIR,
globPatterns: ['**/*.{js,css,html}'],
swDest: tempy.file(),
};
const REQUIRED_PARAMS = [
Expand Down
9 changes: 5 additions & 4 deletions test/workbox-build/node/entry-points/get-manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe(`[workbox-build] entry-points/get-manifest.js (End to End)`, function()
const SRC_DIR = path.join(__dirname, '..', '..', 'static', 'example-project-1');
const BASE_OPTIONS = {
globDirectory: SRC_DIR,
globPatterns: ['**/*.{js,css,html}'],
};
const REQUIRED_PARAMS = ['globDirectory'];
const SUPPORTED_PARAMS = [
Expand Down Expand Up @@ -119,9 +120,9 @@ describe(`[workbox-build] entry-points/get-manifest.js (End to End)`, function()
});

it(`should use defaults when all the required parameters, and 'globPatterns' are present`, async function() {
const options = Object.assign({
const options = Object.assign({}, BASE_OPTIONS, {
globPatterns: ['**/*.html', '**/*.js'],
}, BASE_OPTIONS);
});

const {count, size, manifestEntries} = await getManifest(options);

Expand Down Expand Up @@ -161,10 +162,10 @@ describe(`[workbox-build] entry-points/get-manifest.js (End to End)`, function()
});

it(`should use defaults when all the required parameters, 'globIgnores', and 'globPatterns' are present`, async function() {
const options = Object.assign({
const options = Object.assign({}, BASE_OPTIONS, {
globPatterns: ['**/*.css', '**/*.js'],
globIgnores: ['node_modules/**/*', '**/*2*'],
}, BASE_OPTIONS);
});

const {count, size, manifestEntries} = await getManifest(options);

Expand Down
1 change: 1 addition & 0 deletions test/workbox-build/node/entry-points/inject-manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe(`[workbox-build] entry-points/inject-manifest.js (End to End)`, functio
const SW_SRC_DIR = path.join(__dirname, '..', '..', 'static', 'sw-injections');
const BASE_OPTIONS = {
globDirectory: GLOB_DIR,
globPatterns: ['**/*.{js,css,html}'],
swDest: tempy.file(),
swSrc: path.join(SW_SRC_DIR, 'basic.js'),
};
Expand Down
6 changes: 3 additions & 3 deletions test/workbox-build/node/entry-points/options/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe(`[workbox-build] entry-points/options/validate.js`, function() {
expect(options).to.eql({
globFollow: true,
globIgnores: ['**/node_modules/**/*'],
globPatterns: ['**/*.{js,css,html}'],
globPatterns: [],
globStrict: true,
maximumFileSizeToCacheInBytes: 2097152,
});
Expand All @@ -39,7 +39,7 @@ describe(`[workbox-build] entry-points/options/validate.js`, function() {
expect(options).to.eql({
globFollow: true,
globIgnores: ['**/node_modules/**/*'],
globPatterns: ['**/*.{js,css,html}'],
globPatterns: [],
globStrict: true,
maximumFileSizeToCacheInBytes,
});
Expand All @@ -53,7 +53,7 @@ describe(`[workbox-build] entry-points/options/validate.js`, function() {
dontCacheBustUrlsMatching,
globFollow: true,
globIgnores: ['**/node_modules/**/*'],
globPatterns: ['**/*.{js,css,html}'],
globPatterns: [],
globStrict: true,
maximumFileSizeToCacheInBytes: 2097152,
});
Expand Down

0 comments on commit 1aed68d

Please sign in to comment.