From 7e58960fe9f2ef3d8b07fa978bf94c7f1dac98f2 Mon Sep 17 00:00:00 2001
From: Kushagra Gour <chinchang457@gmail.com>
Date: Thu, 25 Oct 2018 22:29:14 +0530
Subject: [PATCH] extension: fix path for worker

---
 gulpfile.js  | 2 +-
 src/utils.js | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/gulpfile.js b/gulpfile.js
index 16179f6..6600f0a 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -165,7 +165,7 @@ gulp.task('generate-service-worker', function(callback) {
 });
 
 gulp.task('packageExtension', function() {
-	child_process.execSync('cp -R app extension/');
+	child_process.execSync('cp -R app extension');
 	child_process.execSync('cp src/manifest.json extension');
 	child_process.execSync('cp src/options.js extension');
 	child_process.execSync('cp src/options.html extension');
diff --git a/src/utils.js b/src/utils.js
index 3b51630..8ea281c 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -462,7 +462,11 @@ export function getFilenameFromUrl(url) {
 
 export function prettify(content, type = 'js') {
 	const d = deferred();
-	const worker = new Worker(`${BASE_PATH}/lib/prettier-worker.js`);
+	const worker = new Worker(
+		chrome.extension
+			? chrome.extension.getURL('lib/prettier-worker.js')
+			: `${BASE_PATH}/lib/prettier-worker.js`
+	);
 	worker.postMessage({ content, type });
 	worker.addEventListener('message', e => {
 		d.resolve(e.data);