Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
BroccoliWorkbox.prototype.build = function() {
const workboxOptions = Object.assign({}, this.workboxOptions);
const directory = this.inputPaths[0];
if (!this.options.enabled) {
debug(yellow('Addon disabled. Generating empty service worker...'));
workboxOptions.globPatterns = [];
workboxOptions.runtimeCaching = [];
}
workboxOptions.globDirectory = path.join(directory, workboxOptions.globDirectory);
workboxOptions.swDest = path.join(directory, workboxOptions.swDest);
let cleanPromise = Promise.resolve();
const workboxDirectory = path.join(directory, `workbox-v${workboxBuildPkg.version}`);
// Remove workbox libraries directory to prevent exception on recopying it.
if (!workboxOptions.importWorkboxFromCDN && fs.existsSync(workboxDirectory)) {
cleanPromise = cleanDir(workboxDirectory);
}
const filesToIncludeInSW = glob.sync('assets/service-workers/*.js',
{ cwd: workboxOptions.globDirectory }
);
workboxOptions.importScripts = filesToIncludeInSW;
if (this.options.importScriptsTransform) {
workboxOptions.importScripts = this.options.importScriptsTransform(workboxOptions.importScripts);
}
return cleanPromise.then(() =>