{"action":"created","comment":{"url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/pulls/comments/44993127","id":44993127,"diff_hunk":"@@ -29,118 +20,31 @@ module.exports = function(context) {\n         return Q();\n     }\n \n-    // Validate whether all platforms are currently supported\n-    // If a platform is not supported by the plugin, display an error message and don't process it any further\n-    options.platforms.forEach(function(plat, index, platforms) {\n-        if (!multiPlatforms.isPlatformSupported(plat)) {\n-            var msg = 'The \"' + plat + '\" platform is not supported.';\n-            logger.show(msg);\n-            platforms.splice(index, 1);\n-        }\n-    });\n-\n-    // If none of the supplied platforms are supported, stop and return an error\n-    if (options.platforms === undefined || options.platforms.length === 0) {\n-        var msg = 'None of the platforms supplied are currently supported for LiveReload.';\n-        logger.show(msg);\n-        return Q.reject(msg);\n-    }\n-\n-    var platform_wwws = options.platforms.map(function(plat) {\n-        return path.join(projectRoot, multiPlatforms.getPlatformWWWFolder(plat));\n-    });\n-\n-    var startPage = helpers.GetStartPage(projectRoot),\n-        LiveReload = require('./livereload'),\n-        livereloadOptions = helpers.parseOptions();\n-\n-\n-    // If user has entered whitespaces surrounding '--ignore', \n-    // ... we end up having helpers.parseOptions() return 'ignore' with value true instead of a string,\n-    // ... which can't be used as a string. So, Let's check for those cases\n-    // e.g of error cases: \n-    //      `cordova run android -- --livereload --ignore, // with no path to ignore\n-    //      `cordova run android -- --livereload --ignore= css, // with space after the '=' sign\n-    //      etc...\n-    // ToDO: ignore whitespaces surrounding the --ignore option or at least display a warning message to user\n-    var ignoreOption = undefined;\n-    if (livereloadOptions.ignore) {\n-        ignoreOption = path.join(projectRoot, 'www', livereloadOptions.ignore);\n-    }\n-\n-    var lr = new LiveReload(projectRoot, platform_wwws, {\n-        files: [{\n-            match: [path.join(projectRoot, 'www', '**/*.*')],\n-            fn: function(event, file) {\n-                // After a file changes, first run `cordova prepare`, then reload.\n-                context.cordova.raw.prepare().then(function() {\n-                    // Remove CSP directive from HTML\n-                    platform_wwws.forEach(function(platWWWDir) {\n-                        var platformIndexLocal = path.join(platWWWDir, startPage);\n-                        var remover = new CSPRemover(platformIndexLocal);\n-                        remover.Remove();\n-                    });\n-                    return Q();\n-                }).then(function() {\n-                    if (event === 'change') {\n-                        lr.browserSync.reload(file);\n-                        return Q();\n-                    }\n-\n-                    // If new files got added or deleted, reload the whole app instead of specific files only\n-                    // e.g: index.html references a logo file 'img/logo.png'\n-                    // deleting the 'img/logo.png' file will trigger a reload that will remove it from the rendered app\n-                    // likewise, adding the 'img/logo.png' file will trigger it to be shown on the app\n-                    lr.browserSync.reload();\n-                    return Q();\n-                }).fail(function(err) {\n-                    var msg = ' - An error occurred: ' + err;\n-                    logger.show(msg);\n-                    lr.stopServer();\n-                });\n-            }\n-        }],\n-        watchOptions: {\n-\n-            // If user specified files/folders to ignore (via `cordova run android -- --livereload --ignore=build/**/*.*`), ignore those files\n-            // ... Otherwise, don't ignore any files (That's the default). The function below achieves that goal.\n-            ignored: ignoreOption || function(string) {\n-                return false;\n-            },\n-\n-            // Ignore the initial add events .\n-            // Don't run prepare on the initial addition of files,\n-            // Only do it on subsequent ones\n-            ignoreInitial: true\n-        },\n-        tunnel: livereloadOptions.tunnel || false,\n-        ghostMode: livereloadOptions.ghostMode || true\n-    });\n-\n-    return lr.startServer().then(function(server_url) {\n-        return promiseUtils.Q_chainmap(options.platforms, function(plat) {\n-            var platformIndexUrl = url.resolve(server_url, path.join(multiPlatforms.getPlatformWWWFolder(plat), startPage));\n-            helpers.ChangeStartPage(projectRoot, plat, platformIndexUrl);\n-        });\n-    }).then(function() {\n-        return promiseUtils.Q_chainmap(options.platforms, function(plat) {\n-            var platWWWFolder = multiPlatforms.getPlatformWWWFolder(plat);\n-\n-            var platformIndexLocal = path.join(projectRoot, platWWWFolder, startPage);\n-            var cspRemover = new CSPRemover(platformIndexLocal);\n-            return cspRemover.Remove().then(function() {\n-                var atsRemover = new ATSRemover(projectRoot, plat);\n-                return atsRemover.Remove();\n+    //  Start LiveReload server\n+    var projectRoot = context.opts.projectRoot;\n+    var platforms = context.opts.platforms;\n+\n+    return lr.start(projectRoot, platforms, {\n+        cb: function (event, file, lrHandle) {\n+            // After a file changes, first run `cordova prepare`, then reload.\n+            context.cordova.raw.prepare().then(function () {\n+                var patcher = new lr.Patcher(projectRoot, platforms);\n+                return patcher.removeCSP();\n+            }).then(function () {\n+                if (event === 'change') {\n+                    return lrHandle.reloadFile(file);","path":"lib/postPrepareHook.js","position":143,"original_position":143,"commit_id":"b5a46fda077c5fc27ff940f53ab2a524bc0d55c6","original_commit_id":"b5a46fda077c5fc27ff940f53ab2a524bc0d55c6","user":{"login":"meenakb","id":9556376,"avatar_url":"https://avatars.githubusercontent.com/u/9556376?v=3","gravatar_id":"","url":"https://api.github.com/users/meenakb","html_url":"https://github.com/meenakb","followers_url":"https://api.github.com/users/meenakb/followers","following_url":"https://api.github.com/users/meenakb/following{/other_user}","gists_url":"https://api.github.com/users/meenakb/gists{/gist_id}","starred_url":"https://api.github.com/users/meenakb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meenakb/subscriptions","organizations_url":"https://api.github.com/users/meenakb/orgs","repos_url":"https://api.github.com/users/meenakb/repos","events_url":"https://api.github.com/users/meenakb/events{/privacy}","received_events_url":"https://api.github.com/users/meenakb/received_events","type":"User","site_admin":false},"body":"Would reloading the single changed file work in case of hrefs (lets say, in iframes) referencing this changed file?","created_at":"2015-11-16T22:19:55Z","updated_at":"2015-11-16T22:19:55Z","html_url":"https://github.com/omefire/cordova-plugin-livereload/pull/44#discussion_r44993127","pull_request_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/pulls/44","_links":{"self":{"href":"https://api.github.com/repos/omefire/cordova-plugin-livereload/pulls/comments/44993127"},"html":{"href":"https://github.com/omefire/cordova-plugin-livereload/pull/44#discussion_r44993127"},"pull_request":{"href":"https://api.github.com/repos/omefire/cordova-plugin-livereload/pulls/44"}}},"pull_request":{"url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/pulls/44","id":50458999,"html_url":"https://github.com/omefire/cordova-plugin-livereload/pull/44","diff_url":"https://github.com/omefire/cordova-plugin-livereload/pull/44.diff","patch_url":"https://github.com/omefire/cordova-plugin-livereload/pull/44.patch","issue_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/issues/44","number":44,"state":"open","locked":false,"title":"Expose API endpoints","user":{"login":"omefire","id":4992035,"avatar_url":"https://avatars.githubusercontent.com/u/4992035?v=3","gravatar_id":"","url":"https://api.github.com/users/omefire","html_url":"https://github.com/omefire","followers_url":"https://api.github.com/users/omefire/followers","following_url":"https://api.github.com/users/omefire/following{/other_user}","gists_url":"https://api.github.com/users/omefire/gists{/gist_id}","starred_url":"https://api.github.com/users/omefire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omefire/subscriptions","organizations_url":"https://api.github.com/users/omefire/orgs","repos_url":"https://api.github.com/users/omefire/repos","events_url":"https://api.github.com/users/omefire/events{/privacy}","received_events_url":"https://api.github.com/users/omefire/received_events","type":"User","site_admin":false},"body":"- Expose API Endpoints so that external clients can consume this functionality and use this as an NPM package\r\n- Rework the plugin hook to consume the exposed API Endpoint","created_at":"2015-11-12T00:59:55Z","updated_at":"2015-11-16T22:19:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e9fb18718000dfe243205057afdeb67f9ab9f42d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/pulls/44/commits","review_comments_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/pulls/44/comments","review_comment_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/pulls/comments{/number}","comments_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/issues/44/comments","statuses_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/statuses/b5a46fda077c5fc27ff940f53ab2a524bc0d55c6","head":{"label":"omefire:expose_api_endpoints","ref":"expose_api_endpoints","sha":"b5a46fda077c5fc27ff940f53ab2a524bc0d55c6","user":{"login":"omefire","id":4992035,"avatar_url":"https://avatars.githubusercontent.com/u/4992035?v=3","gravatar_id":"","url":"https://api.github.com/users/omefire","html_url":"https://github.com/omefire","followers_url":"https://api.github.com/users/omefire/followers","following_url":"https://api.github.com/users/omefire/following{/other_user}","gists_url":"https://api.github.com/users/omefire/gists{/gist_id}","starred_url":"https://api.github.com/users/omefire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omefire/subscriptions","organizations_url":"https://api.github.com/users/omefire/orgs","repos_url":"https://api.github.com/users/omefire/repos","events_url":"https://api.github.com/users/omefire/events{/privacy}","received_events_url":"https://api.github.com/users/omefire/received_events","type":"User","site_admin":false},"repo":{"id":41187987,"name":"cordova-plugin-livereload","full_name":"omefire/cordova-plugin-livereload","owner":{"login":"omefire","id":4992035,"avatar_url":"https://avatars.githubusercontent.com/u/4992035?v=3","gravatar_id":"","url":"https://api.github.com/users/omefire","html_url":"https://github.com/omefire","followers_url":"https://api.github.com/users/omefire/followers","following_url":"https://api.github.com/users/omefire/following{/other_user}","gists_url":"https://api.github.com/users/omefire/gists{/gist_id}","starred_url":"https://api.github.com/users/omefire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omefire/subscriptions","organizations_url":"https://api.github.com/users/omefire/orgs","repos_url":"https://api.github.com/users/omefire/repos","events_url":"https://api.github.com/users/omefire/events{/privacy}","received_events_url":"https://api.github.com/users/omefire/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/omefire/cordova-plugin-livereload","description":"Plugin to enable livereload and gestures synchronization across devices for Cordova","fork":false,"url":"https://api.github.com/repos/omefire/cordova-plugin-livereload","forks_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/forks","keys_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/keys{/key_id}","collaborators_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/teams","hooks_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/hooks","issue_events_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/issues/events{/number}","events_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/events","assignees_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/assignees{/user}","branches_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/branches{/branch}","tags_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/tags","blobs_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/git/refs{/sha}","trees_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/git/trees{/sha}","statuses_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/statuses/{sha}","languages_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/languages","stargazers_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/stargazers","contributors_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/contributors","subscribers_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/subscribers","subscription_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/subscription","commits_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/commits{/sha}","git_commits_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/git/commits{/sha}","comments_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/comments{/number}","issue_comment_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/issues/comments{/number}","contents_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/contents/{+path}","compare_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/compare/{base}...{head}","merges_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/merges","archive_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/downloads","issues_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/issues{/number}","pulls_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/pulls{/number}","milestones_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/milestones{/number}","notifications_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/labels{/name}","releases_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/releases{/id}","created_at":"2015-08-22T03:16:46Z","updated_at":"2015-11-03T18:41:33Z","pushed_at":"2015-11-16T21:14:06Z","git_url":"git://github.com/omefire/cordova-plugin-livereload.git","ssh_url":"git@github.com:omefire/cordova-plugin-livereload.git","clone_url":"https://github.com/omefire/cordova-plugin-livereload.git","svn_url":"https://github.com/omefire/cordova-plugin-livereload","homepage":"","size":253,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":9,"forks":1,"open_issues":9,"watchers":6,"default_branch":"master"}},"base":{"label":"omefire:master","ref":"master","sha":"3bb19735bdedd6884b0addc0c16146cfa8b4f5cf","user":{"login":"omefire","id":4992035,"avatar_url":"https://avatars.githubusercontent.com/u/4992035?v=3","gravatar_id":"","url":"https://api.github.com/users/omefire","html_url":"https://github.com/omefire","followers_url":"https://api.github.com/users/omefire/followers","following_url":"https://api.github.com/users/omefire/following{/other_user}","gists_url":"https://api.github.com/users/omefire/gists{/gist_id}","starred_url":"https://api.github.com/users/omefire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omefire/subscriptions","organizations_url":"https://api.github.com/users/omefire/orgs","repos_url":"https://api.github.com/users/omefire/repos","events_url":"https://api.github.com/users/omefire/events{/privacy}","received_events_url":"https://api.github.com/users/omefire/received_events","type":"User","site_admin":false},"repo":{"id":41187987,"name":"cordova-plugin-livereload","full_name":"omefire/cordova-plugin-livereload","owner":{"login":"omefire","id":4992035,"avatar_url":"https://avatars.githubusercontent.com/u/4992035?v=3","gravatar_id":"","url":"https://api.github.com/users/omefire","html_url":"https://github.com/omefire","followers_url":"https://api.github.com/users/omefire/followers","following_url":"https://api.github.com/users/omefire/following{/other_user}","gists_url":"https://api.github.com/users/omefire/gists{/gist_id}","starred_url":"https://api.github.com/users/omefire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omefire/subscriptions","organizations_url":"https://api.github.com/users/omefire/orgs","repos_url":"https://api.github.com/users/omefire/repos","events_url":"https://api.github.com/users/omefire/events{/privacy}","received_events_url":"https://api.github.com/users/omefire/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/omefire/cordova-plugin-livereload","description":"Plugin to enable livereload and gestures synchronization across devices for Cordova","fork":false,"url":"https://api.github.com/repos/omefire/cordova-plugin-livereload","forks_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/forks","keys_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/keys{/key_id}","collaborators_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/teams","hooks_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/hooks","issue_events_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/issues/events{/number}","events_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/events","assignees_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/assignees{/user}","branches_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/branches{/branch}","tags_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/tags","blobs_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/git/refs{/sha}","trees_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/git/trees{/sha}","statuses_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/statuses/{sha}","languages_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/languages","stargazers_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/stargazers","contributors_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/contributors","subscribers_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/subscribers","subscription_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/subscription","commits_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/commits{/sha}","git_commits_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/git/commits{/sha}","comments_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/comments{/number}","issue_comment_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/issues/comments{/number}","contents_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/contents/{+path}","compare_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/compare/{base}...{head}","merges_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/merges","archive_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/downloads","issues_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/issues{/number}","pulls_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/pulls{/number}","milestones_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/milestones{/number}","notifications_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/labels{/name}","releases_url":"https://api.github.com/repos/omefire/cordova-plugin-livereload/releases{/id}","created_at":"2015-08-22T03:16:46Z","updated_at":"2015-11-03T18:41:33Z","pushed_at":"2015-11-16T21:14:06Z","git_url":"git://github.com/omefire/cordova-plugin-livereload.git","ssh_url":"git@github.com:omefire/cordova-plugin-livereload.git","clone_url":"https://github.com/omefire/cordova-plugin-livereload.git","svn_url":"https://github.com/omefire/cordova-plugin-livereload","homepage":"","size":253,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":9,"forks":1,"open_issues":9,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/omefire/cordova-plugin-livereload/pulls/44"},"html":{"href":"https://github.com/omefire/cordova-plugin-livereload/pull/44"},"issue":{"href":"https://api.github.com/repos/omefire/cordova-plugin-livereload/issues/44"},"comments":{"href":"https://api.github.com/repos/omefire/cordova-plugin-livereload/issues/44/comments"},"review_comments":{"href":"https://api.github.com/repos/omefire/cordova-plugin-livereload/pulls/44/comments"},"review_comment":{"href":"https://api.github.com/repos/omefire/cordova-plugin-livereload/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/omefire/cordova-plugin-livereload/pulls/44/commits"},"statuses":{"href":"https://api.github.com/repos/omefire/cordova-plugin-livereload/statuses/b5a46fda077c5fc27ff940f53ab2a524bc0d55c6"}}}}