Skip to content

Commit

Permalink
Moved included files before install
Browse files Browse the repository at this point in the history
Allows included files to use sw-toolbox.
  • Loading branch information
jkleinsc committed Jan 11, 2016
1 parent e33bb21 commit c9b0af4
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,6 @@ BroccoliServiceWorker.prototype.write = function(readTree, destDir) {
}
});
}
if (skipWaiting || debug) {
lines.push("self.addEventListener('install', function(event) {");
addDebugLine("'Handling install event. Resources to pre-fetch:', urlsToPrefetch", debug, lines);
if (skipWaiting) {
lines.push(" if (self.skipWaiting) { self.skipWaiting(); }");
}
lines.push("});");
}
if (swIncludeFiles && swIncludeFiles.length) {
swIncludeFiles.forEach(function(file) {
lines.push(fs.readFileSync(file));
Expand All @@ -109,6 +101,15 @@ BroccoliServiceWorker.prototype.write = function(readTree, destDir) {
lines.push(fs.readFileSync(srcFile));
});
}
if (skipWaiting || debug) {
lines.push("self.addEventListener('install', function(event) {");
addDebugLine("'Handling install event. Resources to pre-fetch:', urlsToPrefetch", debug, lines);
if (skipWaiting) {
lines.push(" if (self.skipWaiting) { self.skipWaiting(); }");
}
lines.push("});");
}

lines.push(getFileContents('delete-old-caches.js'));
if (fallback.length) {
lines.push(getFileContents('fallback-response.js'));
Expand Down

0 comments on commit c9b0af4

Please sign in to comment.