forked from jinzhu/vrome
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-jinzhu#125 scripts to reload extension automatically during dev -- u…
…tils
- Loading branch information
Showing
7 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ Gemfile.lock | |
/src/files/features.html | ||
/src/files/changelog.html | ||
/src/files/thanks.html | ||
/nbproject/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/version.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version.txt -- generated version number. updated whenever a change is made to the js file by watch_and_do scripts | ||
|
||
update_version.rb -- called by watch_and_do to update version.txt | ||
|
||
reload_extension.js -- makes calls to server.rb every X seconds and reloads the extension if the version number has been updated i.e files have been changed | ||
|
||
refresh_server.sh -- reloads the ruby server when files have been modified |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
# script to restart server whenever changes are made | ||
# watch_and_do /home/hassen/workspace/vrome/system/ruby/lib rb /home/hassen/workspace/vrome/refresh_server.sh | ||
pid=`lsof -t -i :20000` | ||
echo $pid | ||
kill -9 $pid | ||
|
||
echo "restarting server..." | ||
nohup ./system/ruby/bin/vrome >> /tmp/vrome_server.out 2>> /tmp/vrome_server.err < /dev/null & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// put your extension ID here | ||
var myExtensionID = 'fecemdkpacpnmlbkjfadknbkfhadnnjm'; | ||
var latestVersion = -1; | ||
var time = 500; // reload every X ms | ||
|
||
function reload_ext() | ||
{ | ||
document.getElementById("toggle-" + myExtensionID).click(); | ||
} | ||
|
||
function reloadExtension() | ||
{ | ||
var xhr = new XMLHttpRequest(); | ||
var url = 'http://127.0.0.1:20000'; | ||
xhr.open("POST", url, true); | ||
xhr.onreadystatechange = function() { | ||
if(xhr.readyState == 4 && xhr.status == 200) { | ||
if(latestVersion != xhr.responseText) | ||
{ | ||
chrome.send('reload', [myExtensionID]); | ||
// recent versions of chrome | ||
reload_ext(); | ||
setTimeout('reload_ext()', 500); | ||
console.log("RELOADING at " + new Date()); | ||
latestVersion = xhr.responseText; | ||
} | ||
} | ||
} | ||
|
||
xhr.setRequestHeader("Content-type", "text/plain"); | ||
xhr.send(JSON.stringify({ | ||
'method':'get_latest_version' | ||
})); | ||
} | ||
|
||
window.setInterval('reloadExtension()', time); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env ruby | ||
|
||
filename = File.dirname(File.expand_path(__FILE__)) + "/version.txt" | ||
|
||
version = 0 | ||
if File.exists? filename | ||
version = eval(File.read(filename)) | ||
end | ||
version += 1 | ||
|
||
tmpfile = File.new filename, "w" | ||
tmpfile.write version | ||
tmpfile.flush | ||
|
||
puts version |