Skip to content

Commit

Permalink
chrome extension auto updater
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnycrab committed Sep 12, 2014
1 parent 3d36614 commit 5757080
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 7 deletions.
27 changes: 24 additions & 3 deletions src/core/ui/routines/UiChromeExtensionRoutine.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/core/ui/routines/UiChromeExtensionRoutine.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 27 additions & 3 deletions src/core/ui/routines/UiChromeExtensionRoutine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,33 @@ class UiChromeExtensionRoutine implements UiRoutineInterface {
public isInstalled (callback:(installed:boolean) => any):void {
var installed:boolean = fs.existsSync(this._getInstallPath()) && fs.existsSync(this._getDestinationCrxPath());

process.nextTick(function () {
callback(installed);
});
var doCallback:Function = function (isInstalled:boolean) {
process.nextTick(function () {
callback(isInstalled);
});
};

if (!installed) {
doCallback(false);
return;
}
else {
// check if it is the right version
try {
var contents:string = fs.readFileSync(this._getInstallPath(), {encoding: 'utf8'});
var obj:any = JSON.parse(contents);

if (obj && obj.external_version === this._config.get('extension.version')) {
doCallback(true);
return;
}
}
catch (e) {
}
}

// fallback
doCallback(false);
}

public start (callback?:(err:Error) => any):void {
Expand Down

0 comments on commit 5757080

Please sign in to comment.